PowerCLI One Liners

(Last Updated On: 02/04/2020)

Useful commands for any number of tasks

Get number of VM’s per datastore

Get-Datastore | Select Name, @{N="NumVM";E={@($_ | Get-VM).Count}} | Sort Name

Get ESX version and builds

get-view –ViewType HostSystem -Property Name,Config.Product | select Name,{$_.Config.Product.FullName}

Check if SSH is running on VMHosts

Get-VMHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } |select VMHost, Label, Running