vSphere PowerCLI One-liners

PowerCLI Logo

Get the time on all ESXi hosts (Compatable with PowerCLI 4.1 up):

get-vmhost | select Name,@{Name="Time";Expression={(get-view $_.ExtensionData.configManager.DateTimeSystem).QueryDateTime()}}


Set the time on all ESXi hosts to the PowerCLI host’s time (Compatable with PowerCLI 4.1 up):

get-vmhost | %{(get-view $_.ExtensionData.configManager.DateTimeSystem).UpdateDateTime((Get-Date -format u)) }


List all RDM disks (use the -Location paramater to narrow it down):

Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName


List the vMotion IP Addresses of all hosts:

Get-VMHost | %{ $VMHost=$_.Name;(get-view $_.id).config.vmotion.ipconfig} | select @{name="Host"; expression={$VMHost}}, ipaddress, subnetmask

CC BY-SA 4.0
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.