Setting VM SDRS automation levels

By | June 11, 2015

I learnt recently that when you Storage vMotion a VM within a datastore cluster and you check the box to select which datastore you explicitly want the VM to be migrated to, it sets the SDRS automation level for the VM to disabled.

Finding out which VMs have an automation level of disabled can be achieved with the following line:

Since I like to have VMs set to the cluster default we need a bit of PowerCLI to change the VMs back. The following code will look at all the datastore clusters on the vCenter, and all the VMs with a disabled automation level therein.

Credit goes to LucD whose posts in the VMware Communities forum formed the base of this script. The threads are here and here.

This script is designed to be used with PowerCLI 6, as per the “Import-Module” statements at the top. For previous versions of PowerCLI the lines should be replaced with adding the appropriate snapin.

If needed, this script can easily be expanded to check for Tags or Custom Attributes assigned to the VM, and only to change the automation level given the presence or absence of a tag or the value of a custom attribute.