Get VMHost Swap datastore using PowerCLI

This is a quick one-liner to get the configured swap datastore on a host/hosts:

1
Get-VMHost | Sort Name | select Name, VMSwapfileDatastore

If we want to make the name look a little nicer we could do:

1
Get-VMHost | Sort Name | select Name, @{L='Swap Datastore';E={ ($_.VMSwapfileDatastore).Name } }

This would get the results for all the esxi hosts for the target that you are connected to, however if you wanted to reduce the scope to a cluster or a datacenter you could change the start to:

1
Get-VMHost -Location <Datacenter / Cluster Name> | ...

Or you could pipe in the location or array of hosts:

1
Get-Cluster <cluster name> | Get-VMHost | ...

or:

1
$array_of_host_objects | ...
Built with Hugo
Theme Stack designed by Jimmy