VMware Cloud Community
the3rdd
Contributor
Contributor
Jump to solution

Enable DRS Automation Help

So I worte a script and I am at a little roadblock. I can set the DRS and I can write-output the rule value I need to verify against however, I can not think of the way needed, to put into the IF statement, so if DRS is already True it will not run the DRSEnabled switch. Any help would be greatly appreciated.

$clusters = get-cluster | where {$_.Name -notmatch 'test01*'}
$rule = $Clusters | select DRSEnabled

write-output $rule

foreach ($cluster in $clusters)
{
  if(    )

{
      Set-Cluster -Cluster $cluster -DRSEnabled:$True -DRSAutomationLevel FullyAutomated -Confirm:0
}

}

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The following PowerCLI one-liner will set all clusters to DRS enabled where DRS was disabled:

Get-Cluster | Where-Object {-not $_.DrsEnabled} | Set-Cluster -DRSAutomationLevel FullyAutomated -Confirm:$false

For your script the if statement should be:

if (-not $cluster.DrsEnabled)

Regards, Robert

Message was edited by: RvdNieuwendijk

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
2 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The following PowerCLI one-liner will set all clusters to DRS enabled where DRS was disabled:

Get-Cluster | Where-Object {-not $_.DrsEnabled} | Set-Cluster -DRSAutomationLevel FullyAutomated -Confirm:$false

For your script the if statement should be:

if (-not $cluster.DrsEnabled)

Regards, Robert

Message was edited by: RvdNieuwendijk

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
the3rdd
Contributor
Contributor
Jump to solution

Worked perfectly, thank you very much. 

0 Kudos