I am trying to find a way in powercli to change the Storage DRS Automation Level to the Default (Fully Automated) on all my VMs.
$si = Get-View ServiceInstance
$srmMgr = Get-View -Id $si.Content.StorageResourceManager
foreach($dsc in Get-DatastoreCluster){
$spec = New-Object VMware.Vim.StorageDrsConfigSpec
foreach($vm in ($dsc.ExtensionData.PodStorageDrsEntry.StorageDrsConfig.VmConfig | where{$_.Behavior -eq [VMware.Vim.StorageDrsPodConfigInfoBehavior]::manual})){
$vmSpec = New-Object VMware.Vim.StorageDrsVmConfigSpec
$vmSpec.Operation = [VMware.Vim.ArrayUpdateOperation]::edit
$vmSpec.Info = $vm
$vmSpec.Info.Behavior = [VMware.Vim.StorageDrsPodConfigInfoBehavior]::FullyAutomated
$spec.VmConfigSpec += $vmSpec
}
$srmMgr.ConfigureStorageDrsForPod($dsc.ExtensionData.MoRef,$spec,$true)
}