Get VMHost Swap datastore using PowerCLI

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

Get-VMHost | Sort Name | select Name, VMSwapfileDatastore

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

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:

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

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

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

or:

$array_of_host_objects | ...