This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
program_lang:powershell_linux [2021/11/11 17:34] manu |
program_lang:powershell_linux [2023/12/04 22:47] (current) manu |
||
---|---|---|---|
Line 2: | Line 2: | ||
Powershell can be downloaded by Microsoft, for example available in rpm package | Powershell can be downloaded by Microsoft, for example available in rpm package | ||
+ | |||
+ | https://learn.microsoft.com/fr-fr/powershell/scripting/install/installing-powershell-on-linux | ||
+ | |||
+ | ==== Powershell ==== | ||
+ | |||
+ | Download Powershell from github | ||
+ | https://github.com/PowerShell/PowerShell/ | ||
+ | https://github.com/PowerShell/PowerShell/releases/download/v7.2.4/powershell-7.2.4-1.rh.x86_64.rpm | ||
+ | |||
+ | Or Microsoft | ||
+ | https://packages.microsoft.com/rhel/7.3/prod/Packages/p/ | ||
+ | | ||
+ | <cli prompt='#'> | ||
+ | [root@rhel8] ~ # rpm -Uhv /work/powershell-7.2.4-1.rh.x86_64.rpm | ||
+ | |||
+ | [root@rhel8] ~ # pwsh | ||
+ | PowerShell 7.2.4 | ||
+ | Copyright (c) Microsoft Corporation. | ||
+ | |||
+ | https://aka.ms/powershell | ||
+ | Type 'help' to get help. | ||
+ | |||
+ | PS /root> | ||
+ | </cli> | ||
+ | |||
+ | Install module PowerCLI : https://developer.vmware.com/powercli/installation-guide | ||
+ | |||
+ | Check module folders: | ||
+ | <cli prompt='>'> | ||
+ | PS /work> $env:PSModulePath | ||
+ | /root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules | ||
+ | PS /work> ls /root/.local/share/powershell/Modules | ||
+ | PS /work> ls /usr/local/share/powershell/Modules | ||
+ | /bin/ls: cannot access /usr/local/share/powershell/Modules: No such file or directory | ||
+ | PS /work> ls /opt/microsoft/powershell/7/Modules | ||
+ | Microsoft.PowerShell.Archive Microsoft.PowerShell.Management Microsoft.PowerShell.Utility PowerShellGet PSReadLine | ||
+ | Microsoft.PowerShell.Host Microsoft.PowerShell.Security PackageManagement PSDesiredStateConfiguration ThreadJob | ||
+ | </cli> | ||
+ | |||
+ | We 'll extract the downloaded module from VMware web site: VMware-PowerCLI-12.4.1-18769701.zip into the folder **/opt/microsoft/powershell/7/Modules** (offline install) | ||
+ | <cli prompt='#'> | ||
+ | [root@rhel8] /opt/microsoft/powershell/7/Modules # unzip /home/cyberark/VMware-PowerCLI-12.4.1-18769701.zip | ||
+ | Archive: /home/cyberark/VMware-PowerCLI-12.4.1-18769701.zip | ||
+ | warning: /home/cyberark/VMware-PowerCLI-12.4.1-18769701.zip appears to use backslashes as path separators | ||
+ | inflating: VMware.CloudServices/EULA.rtf | ||
+ | inflating: VMware.CloudServices/VMware.CloudServices.cat | ||
+ | inflating: VMware.CloudServices/VMware.CloudServices.psd1 | ||
+ | inflating: VMware.CloudServices/VMware.CloudServices.psm1 | ||
+ | inflating: VMware.CloudServices/net45/ComponentDescriptor-VMware.CloudServices.Commands.xml | ||
+ | inflating: VMware.CloudServices/net45/ComponentDescriptor-VMware.CloudServices.Impl.xml | ||
+ | </cli> | ||
+ | |||
+ | Once the modules extracted | ||
+ | <cli prompt='>'> | ||
+ | PS /work> Get-Module | ||
+ | |||
+ | ModuleType Version PreRelease Name ExportedCommands | ||
+ | ---------- ------- ---------- ---- ---------------- | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…} | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…} | ||
+ | Script 2.1.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…} | ||
+ | |||
+ | PS /work> Get-Module -ListAvailable | ||
+ | |||
+ | Directory: /opt/microsoft/powershell/7/Modules | ||
+ | |||
+ | ModuleType Version PreRelease Name PSEdition ExportedCommands | ||
+ | ---------- ------- ---------- ---- --------- ---------------- | ||
+ | Manifest 1.2.5 Microsoft.PowerShell.Archive Desk {Compress-Archive, Expand-Archive} | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Host Core {Start-Transcript, Stop-Transcript} | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Management Core {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path…} | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Security Core {Get-Credential, Get-ExecutionPolicy, Set-ExecutionPolicy, ConvertFrom-SecureString…} | ||
+ | Manifest 7.0.0.0 Microsoft.PowerShell.Utility Core {Export-Alias, Get-Alias, Import-Alias, New-Alias…} | ||
+ | Script 1.4.7 PackageManagement Desk {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…} | ||
+ | Script 2.2.5 PowerShellGet Desk {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…} | ||
+ | Script 2.1.0 PSReadLine Desk {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLineOption…} | ||
+ | Binary 2.0.3 ThreadJob Desk Start-ThreadJob | ||
+ | Script 12.4.0.18… VMware.CloudServices Desk {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get-VcsService…} | ||
+ | Script 7.0.2.178… VMware.DeployAutomation Desk {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, Add-ScriptBundle…} | ||
+ | Script 7.0.2.178… VMware.ImageBuilder Desk {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-EsxImageProfile, Export-EsxImageProfile…} | ||
+ | Manifest 12.4.1.18… VMware.PowerCLI Desk | ||
+ | Script 12.4.1.18… VMware.PowerCLI.Sdk Core,Desk | ||
+ | Script 12.4.1.18… VMware.PowerCLI.Sdk.Types Core,Desk | ||
+ | Script 12.4.1.18… VMware.PowerCLI.VCenter Core,Desk {Get-VIMachineCertificate, Get-VITrustedCertificate, Remove-VITrustedCertificate, New-VIMachineCertificateSigningRequ… | ||
+ | Script 12.4.1.18… VMware.PowerCLI.VCenter.Types.Cert… Core,Desk | ||
+ | ... | ||
+ | </cli> | ||
+ | |||
+ | <cli prompt='>'> | ||
+ | PS /opt/microsoft/powershell/7/Modules> Get-Module -Name VMware.PowerCLI -ListAvailable | ||
+ | |||
+ | Directory: /opt/microsoft/powershell/7/Modules | ||
+ | |||
+ | ModuleType Version PreRelease Name PSEdition ExportedCommands | ||
+ | ---------- ------- ---------- ---- --------- ---------------- | ||
+ | Manifest 12.4.1.18… VMware.PowerCLI Desk | ||
+ | </cli> | ||
+ | |||
+ | If you want installing modules using an internet connection: | ||
Execute the below command to install VMware PowerCLI module (requires internet connection) | Execute the below command to install VMware PowerCLI module (requires internet connection) | ||
Line 9: | Line 108: | ||
</cli> | </cli> | ||
- | Else offline module installation is also available for example PowerCLI | ||
- | https://developer.vmware.com/powercli/installation-guide | ||
- | | ||
Check PowerShell module PATH | Check PowerShell module PATH | ||
<cli prompt='>'> | <cli prompt='>'> | ||
PS /root> $env:PSModulePath | PS /root> $env:PSModulePath | ||
- | </cli> | ||
- | |||
- | Execute the below command to list available modules | ||
- | <cli prompt='>'> | ||
- | PS /root> Get-Module -Name VMware.PowerCLI -ListAvailable | ||
</cli> | </cli> | ||