VMware Cloud Community
Spectrum1981
Enthusiast
Enthusiast

DRS Host affinity rules

Hello together,

in our script we can disable or activate drs rules (Keep vm together or seperate them).

$drs_regeln = Get-DrsRule –Cluster $cluster_object

if ($drs_regeln -eq $null)

{

Write-Host "# No DRS"

}

else

{

foreach($drsrules in $drs_regeln)

{

    if ($drsrules.enabled -eq $true)

    {

        Set-DrsRule -Rule $drsrules -Enabled $false

      

    }

}

Write-Host "# DRS off"

}

But how can i get host affinity rules and deactive them? I found nothing in the WWW. Your my last hope Smiley Happy

Thanks. Rainer

0 Kudos
2 Replies
Zsoldier
Expert
Expert

I'd recommend using Onyx if the built in powercli cmdlets don't get you the information you need.

That'll help you construct something in a script.

Onyx – VMware Labs

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos
LucD
Leadership
Leadership

To retrieve DRS host affinity rules, you can do

Get-DrsRule -Cluster its -Type VMHostAffinity

To change such a host affinity DRS rule you have to revert to the API.

See for example 5.  Re: How to set vm-to-host affinity rule using PowerCLI 5.1


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos