VMware Cloud Community
ramseyd
Contributor
Contributor
Jump to solution

How to find affinity rules in all clusters within one vCenter

Anyone know a command to find affinity rules for each cluster within each datacenter in a vCenter for all VMs? I need to remove all affinity rules in all clusters located in each datacenter within one vcenter. Any ideas?

0 Kudos
1 Solution

Accepted Solutions
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Previous post was almost there. This should provide what you're looking for:

ForEach ($dc in Get-Datacenter){

  $dc|Get-Cluster|Get-DrsRule|Where {$_.type -eq "VMAffinity"}|Sort cluster|Select Name,Cluster,Enabled,@{N='DataCenter';E={$dc}}

  }

View solution in original post

0 Kudos
3 Replies
ramseyd
Contributor
Contributor
Jump to solution

I think its something like this even though i know this doesn't work....

foreach($dc in Get-Datacenter){

foreach ($cluster in (Get-Cluster -Location $DC)) | Get-DRSRule

0 Kudos
kwhornlcs
Enthusiast
Enthusiast
Jump to solution

Previous post was almost there. This should provide what you're looking for:

ForEach ($dc in Get-Datacenter){

  $dc|Get-Cluster|Get-DrsRule|Where {$_.type -eq "VMAffinity"}|Sort cluster|Select Name,Cluster,Enabled,@{N='DataCenter';E={$dc}}

  }

0 Kudos
ramseyd
Contributor
Contributor
Jump to solution

Thank you!!!

0 Kudos