VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

Storage Cluster DRS Auto Level Disabled

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos