I have a scripted process to create a new VM. The script goes through and asks questions about VM type, IP, location, datastore clusters, etc. etc. and then creates the VM with a somewhat simple one liner:
#Creates the new VM
New-VM -Name $myVM -Template $myTemplate -OSCustomizationSpec $osCust -Datastore $myDatastoreCluster -ResourcePool $myCluster
All of the variables are determined based on the questions. The only 2 issues I have are 1) the storage policy isn't set, and 2) it puts an entry into the VM overrides in the datastore cluster. It puts the entries as the default, but since I do have some manually added SDRS VM overrides set, it's annoying to see one for every new build.
#1 I'm solving with PowerCLI 5.8.
#2 is where I'm struggling. I'm looking for either a way to have the VM created without the SDRS VM override entry, or to immediately delete this entry once it's set.
This thread: changing vm storage drs automation level details how to do this on a datastore cluster level, but is there a better way to do this on a specific VM level?