I have been doing some storage migrations and during the process I have disabled SDRS during it, but I thought I had a script to re-enable this once a week, but when I look at the webUI it looks like it hasn't been working. Attached is the script and the screen shot of the webUI.
Thank you for your help,
Andy
Try like this. Afaik Operation is a required property.
Note that the VM entries will disappear if they correspond with the datastorecluster defaults.
#############################
# Connect to vCenter #
#############################
Import-Module -Name VMware.PowerCLI
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -InvalidCertificateAction ignore -confirm:$false
$vc = 'IP'
$Cred = Import-Clixml C:\util\Scripts\creds\autoitjob2.xml
Connect-VIServer $VC -Credential $Cred
#############################
# Content #
#############################
$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{!$_.Enabled})){
$vmSpec = New-Object VMware.Vim.StorageDrsVmConfigSpec
$vmSpec.Operation = [VMware.Vim.ArrayUpdateOperation]::edit
$vmSpec.Info = $vm
$vmSpec.Info.Enabled = $true
$spec.VmConfigSpec += $vmSpec
}
$srmMgr.ConfigureStorageDrsForPod($dsc.ExtensionData.MoRef,$spec,$true)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this. Afaik Operation is a required property.
Note that the VM entries will disappear if they correspond with the datastorecluster defaults.
#############################
# Connect to vCenter #
#############################
Import-Module -Name VMware.PowerCLI
Set-PowerCLIConfiguration -DisplayDeprecationWarnings $false -InvalidCertificateAction ignore -confirm:$false
$vc = 'IP'
$Cred = Import-Clixml C:\util\Scripts\creds\autoitjob2.xml
Connect-VIServer $VC -Credential $Cred
#############################
# Content #
#############################
$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{!$_.Enabled})){
$vmSpec = New-Object VMware.Vim.StorageDrsVmConfigSpec
$vmSpec.Operation = [VMware.Vim.ArrayUpdateOperation]::edit
$vmSpec.Info = $vm
$vmSpec.Info.Enabled = $true
$spec.VmConfigSpec += $vmSpec
}
$srmMgr.ConfigureStorageDrsForPod($dsc.ExtensionData.MoRef,$spec,$true)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference