VMware Cloud Community
PSScripter
Enthusiast
Enthusiast
Jump to solution

List Anti Affintiy rules

Hi folks,

I need to get all the AA rules for a bunch of VMs.

This here is the format I was looking for, can anyone modify this so it fills in the "VMNames" column? As it is now it outputs everything except that column has System.Object[] in it , instead of the VMs that comprise the rule

Get-DrsRule -Cluster $cluster | select Cluster,Name,KeepTogether,Enabled, @{N="VMnames";E={ $_.Vmids|%{(get-view -id $_).name}}} | Export-Excel c:\temp\AArules-myservers.xlsx -AutoFilter -AutoSize

 Thanks!

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-DrsRule -Cluster $cluster |
Select-Object Cluster, Name, KeepTogether, Enabled, 
  @{N = "VMnames"; E = { ($_.Vmids | ForEach-Object { (Get-View -Id $_).name}) -join '|'}}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-DrsRule -Cluster $cluster |
Select-Object Cluster, Name, KeepTogether, Enabled, 
  @{N = "VMnames"; E = { ($_.Vmids | ForEach-Object { (Get-View -Id $_).name}) -join '|'}}


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

0 Kudos
PSScripter
Enthusiast
Enthusiast
Jump to solution

That is exactly what I was looking for, thanks LucD.

0 Kudos