PowerCLI 101 – Changing the VM Swapfile Location

This came up whilst doing preparation and writing for a forthcoming exam prep book. There was an objective that required changing the location of a VM Swap file. There are two PowerCLI one-liners that can help you here. One for the cluster level, then one for the hosts.

PowerCLI – Change the VM Swapfile location at the Cluster level

Get-Cluster -name “Dragons Nest” | Set-Cluster -VMSwapfilePolicy InHostDatastore

PowerCLI – Change the VM Swapfile location at the host level

Get-Cluster -name “Dragons Nest” | Get-VMHost | Set-VMHost -VMSwapfileDatastore “*local*”

Keep in mind, these are both one-liners, so you may need to do some copy/pasta-fu on them (along with changing cluster names, etc).

One thought on “PowerCLI 101 – Changing the VM Swapfile Location”

Comments are closed.