Quick PowerCLI #1

I may or may not make this a series ;) PowerShell with VMware is very useful. Ignoring the Connect-VIServer and Disconnect-VIServer commands, here are some tips.

Getting the Swap File Datastore for all hosts in a cluster

If you store VM swap files away from the VM folder (faster disk I would hope) and have more than one datastore for doing this then you’ll want to separate the datastores used for each host.

1
get-vmhost -location "(cluster name)" | sort Name | ft Name, VMSwapfileDatastore

Getting the Tools Version for a VM

I prefer the first way because it’s slightly less to type ;). With get-vm (the second query) you can target containers that you can’t with get-vmguest. So it’s all a matter of choice !

1
2
get-vmguest "(name/match query)" | ft VM, @{Name="ToolsVersion";Expression={$_.ExtensionData.ToolsVersion}}
get-vm "(name/match query)" | ft Name, @{Name="ToolsVersion";Expression={$_.ExtensionData.Config.Tools.ToolsVersion}}
Built with Hugo
Theme Stack designed by Jimmy