VM Swap File Policy Comes down to three choices : WithVM, On a Defined Datastore, or Inherit from on high.

Now if that isn’t clear enough, there are also potentially three different places where you can set the VM’s Swap File Policy. These are on the VM, on the cluster, or if there isn’t a cluster, on the host itself.

Here is the setting in the VM


Here is the setting in the host


And here is the setting in the cluster


Now that we know what it all looks like in the GUI how do we do it with PowerCLI? I enjoy asking and answering my own questions….

First lets look at how to view what the actual setting currently is.  It is also important to see what the possible settings are….so we know how to refer to them later.


So with this example we see there are the three settings, Inherit, WithVM, and InHostDatastore.

For this specific environment, you might notice that even though these three VMs have different settings, however looking at my earlier screen shots it becomes clear that in this case these three setting currently all mean the same thing….Store the Swap File in the VM directory.

So let’s look at how to change that…

First let’s look at Set-VM and it’s parameter VMSwapFilePolicy


It looks like this parameter is the one we want. Although it doesn’t mention it, another valid paramter value would be “Inherit”, which would mean get your settings from the cluster/host.

Setting the Swapfile Location on the host we look at…Set-VMHostSet-VMHostSwapfile

This one is a bit different because if you wanted to set the VM Swap File Location to a specific datatstore, you would actually need to have values for both of these parameters

Setting the Swapfile location on the cluster we look at… You Guessed It, Set-Cluster


Fortunately we are back to only on parameter for this one, VMSwapfilePolicy with values either being “InHostDatastore” or “WithVM”.

One other thing to mention, is that with this setting, the more granular setting wins. In other words even if you have a Swapfile datastore defined on your host/cluster, if your VM has the setting “WithVM”, the swap file will stick with the VM.

Hope This Helps. Let me know if you have Questions!


Leave a Reply