vmware: useful powercli commands

List all LUNs that are not set to Round Robin:
Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"}

Set all LUNs that are not set to Round Robin to Round Robin:
Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Set-Scsilun -MultiPathPolicy RoundRobin

List all VMs in a cluster:
Get-Cluster "Cluster Name" | Get-VM | Sort Name

List all services running on a host:
Get-VMHost "hostname" | Get-VMHostService | Select Key,Label

List servers with SSH server status:
Get-vmhost | Get-VMHostService | ? {($_.Key -eq "TSM-ssh")} | Select VMHost, Key,Label, Running

List servers with ESXi shell status:
Get-vmhost | Get-VMHostService | ? {($_.Key -eq "TSM")} | Select VMHost, Key,Label, Running

List servers with SSH server status in specific cluster:
Get-Cluster -Name "Non-Production-Pod-01" | get-vmhost | Get-VMHostService | ? {$_.Key -eq "TSM-ssh"} | Select VMHost, Key,Label, Running

Start ESX Shell on all hosts in vCenter:
Get-VMHost | Foreach {
Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM"} | Set-VMHostService -policy "on" -Confirm:$false)
}

Start ssh on all hosts in vCenter:
Get-VMHost | Foreach {
Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} | Set-VMHostService -policy "on" -Confirm:$false)
}

Suppress ssh alert on all hosts in vCenter:
Get-VMHost | Get-AdvancedSetting UserVars.SuppressShellWarning | Set-AdvancedSetting -Value 1

Create VM:
New-VM -RunAsync –name $servername –Datastore $datastore –Template $template –OSCustomizationSpec $spec –ResourcePool $host/resource pool -Location $folder