VMware just announced the new version of VMware PowerCLI 10.0.0 that also coincides with the ten year anniversary of PowerCLI – and now it is easier than ever to have it running on your *nix environment.
- Go to the PowerShell GitHub page and select your desired platform on which you will want to have it running on for installation instructions:
- Once you have successfully installed PowerShell on your desired system, it is time to install PowerCLI – and with version 10 it is easier than ever!
- Start PowerShell with sudo pwsh
- As the PowerCLI modules have been for some time on the PowerShell Gallery we can simply install them with one command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser
- As this version of PowerCLI handles a bit differently self-signed certs (or invalid ones) we need to ignore them:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
- Once all the above is done, here is the moment of truth – connecting as you would’ve from your Windows environment:





Pingback: CentOS7に PowerCLI をインストールするには? – cjnotes
Hi Corin thank for sharing this guide, really appreciated!
Anyway I have a script that is working on windows but doesn’t work within linux powercli. This is the script:
——————————
$vcenters = “myvcenterxxx” #list of vCenter servers
foreach ($vc in $vcenters)
{
if( Connect-VIServer -server $vc -User myuser -Password mypass)
{
Write-Host “vCenter $vc Connected” -ForegroundColor Cyan
}
else
{
Write-Host “Failed to Connect vCenter $vc” -ForegroundColor Cyan
}
}
$VMs = Get-VM|Where-object {$_.powerstate -eq “poweredon”}
$Output = foreach ($VM in $VMs){
Get-VM $VM | select Name,
@{N=”FolderName”;E={ $_.Folder.Name}},
PowerState,
GuestOS,
@{N=”VcenterReference”;E={($vm).ExtensionData.Client.ServiceUrl.Split(‘/’)[2].trimend(“:443″)}},
@{N=”ClusterName”;E={($vm | Get-Cluster)}},
VMHost,
NumCpu,
MemoryGB,
@{N=”CPUUsage”;E={$_.ExtensionData.Summary.QuickStats.OverallCpuUsage}},
@{N=”MemoryUsage”;E={$_.ExtensionData.Summary.QuickStats.GuestMemoryUsage}},
@{N=”StorageFormat”;E={(Get-Harddisk $_).Storageformat}},
@{N=”ProvisionedSpace(GB)”; E={[math]::round($_.ProvisionedSpaceGB)}},
@{N=”UsedSpace(GB)”; E={[math]::round($_.UsedSpaceGB)}},
@{N=”ScsiController”;E={(Get-ScsiController $_).BusSharingMode}},
@{N=”Persistence”;E={(Get-Harddisk $_).Persistence}},
@{N=”Datastore”;E={$_.ExtensionData.Config.DatastoreUrl.Name}},
@{N=”SnapshotCount”;E={(Get-Snapshot -VM $_ | Measure-Object -Sum SizeMB).count}},
@{N=”SnapshotTotalSize”;E={(Get-Snapshot -VM $_ | Measure-Object -Sum SizeMB).Sum}},
@{N=”Real-OS”;E={$_.ExtensionData.summary.config.guestfullname}},
@{N=”NetworkInterfaces”;E={$_.Guest.Nics -join “; “;}},
@{N=”IPAddress”;E={$_.Guest.IPAddress}},
@{N=”PortGroup”;E={($vm | Get-NetworkAdapter).NetworkName -join “; “;}},
@{N=”DNSName”;E={$_.ExtensionData.Guest.Hostname}},
@{N=”VirtualHardwareVersion”;E={$_.version}},
@{N=”Tools Installed”;E={$_.Guest.ToolsVersion -ne “”}},
@{N=”Tools Status”;E={$_.ExtensionData.Guest.ToolsStatus}},
@{N=”Tools version”;E={if($_.Guest.ToolsVersion -ne “”){$_.Guest.ToolsVersion}}}
}
$Output | Export-Csv /tmp/list.txt -Delimiter “;” -NoTypeInformation
Disconnect-VIServer -Server * -Force -confirm:$false
——————————
When I run it on Linux it stucks. Thi is the output
[root@tstmgmtlnx01]# pwsh -F vsphereinventory.ps1
Name Port User
—- —- —-
myvcenterxxx 443 mydomain\mypwd
WARNING: The ‘Version’ property of VirtualMachine type is deprecated. Use the ‘HardwareVersion’ property instead.
No errors are displayed, it just doesn’t go on…
Do you have some idea?
Thanks
Marco
Hopefully someday a bash powerCLI equivalent will appears…
PowerShell syntax is so awful.
Just what it says, newer PowerShell will not allow older ‘deprecated’ values — it wants $_.hardwareversion instead of $_.version in your example.
## @{N=”VirtualHardwareVersion”;E={$_.version}},
@{N=”VirtualHardwareVersion”;E={$_.hardwareversion}},
To Author:
Nice catch on the -InvalidCertificationAction — that has been warning for a long time…