VMware Cloud Community
RahmanK
Contributor
Contributor

PowerCLI Script to Sort hosts by number of ResourcePools

Hi,


I have been trying to write a script to output a list of hosts and order them by lowest number of resources pools.

SCRIPT

Param($location)

$vmhost_list = Get-VMHost -Location $location | Sort

$tgtVmHost = $vmhost_list |

        Get-ResourePool |

        Group-Object -Property Parent |

        Sort-Object -Property {$_.Group.Count}


OUTPUT

Count                     Name                        Group

-----                          ----                             -----

    1                     HOST A                      {Resources}

    1                     HOST B                      {Resources}

    1                     HOST C                      {Resources}

   39                    Resources                   {Env178_79_Net2, Env179_79_Net3, Env182_79_Net6, Env186_79_Net10...}

As you can see the script output is grouping all the resource pools under a host called 'Resources' which does not exist. When in reality HOST A, B and C each contain 13 resource pools (14 including the hidden resourcepool).

How can I edit this script in order to get a more accurate representation.

0 Kudos
0 Replies