As per http://communities.vmware.com/message/2172311#2172311
I'm using LucD's method, to extract a list of vm's that have vm's turned on
This successfully gets a list of vm's that have sdrs enabled that shouldnt.
I'm struggling with how to disable sdrs. I'm new to powershell
from what i can gather i need to update dsc.podstoragedrsentry.storagedrsconfig.vmconfig.enabled to False.
but i'm unsure how to do this, or could point me in the right direction?
Couple things here- The reason you're getting an error is because you're setting the Info properties to empty strings, which is different than null. Empty string is an invalid value.
But I was unable to get it to say "Default" with the "Edit" operation. I could set it to "Fully Automated" by (info.behavior="automated" and info.enabled=$true), but that isn't exactly what you wanted. Setting them to $null didn't work as I expected.
But it seems that the "Add" operation instead of "Edit" will overwrite the existing configuration for a given VM, allowing you to get back to defaults.
I think this should get you what you want:
$storMgr = Get-View StorageResourceManager $spec = New-Object VMware.Vim.StorageDrsConfigSpec $dsc = Get-Datastorecluster DS1 get-vm -Datastore $dsc |%{ $vmEntry = New-Object VMware.Vim.StorageDrsVmConfigSpec $vmEntry.Operation = "add" $vmEntry.Info = New-Object VMware.Vim.StorageDrsVmConfigInfo $vmEntry.Info.Vm = $_.ExtensionData.MoRef $spec.vmConfigSpec += $vmEntry } $storMgr.ConfigureStorageDrsForPod($dsc.ExtensionData.MoRef,$spec,$true)
It's exactly what I want and it works perfectly ! ![]()
Thanks !
Not sure if this was ever figured out, but you can build out the same objects using Get-Datastore | Get-VM instead of grabbing the list of VMs from the datastore cluster settings which appears to have issues. The altered code is below:
$pod | Get-VM | Where-Object {$_.Name -like "*volume*"} |
%{
$_.Name
$entry = New-Object VMware.Vim.StorageDrsVmConfigSpec
$entry.Info = New-Object VMware.Vim.StorageDrsVmConfigInfo
$entry.Operation = "edit"
$entry.Info.VM = $_.ExtensionData.MoRef
$entry.Info.Enabled = $false
$spec.vmConfigSpec += $entry
}
