Powershell script to list resource pools lesser than 'n' VMs

These are just basic powershell scripts. You can use your own logic to enhance this.

#To list resource pools lesser than n vms

cls

#Connect to Vcenter


Connect-VIServer -Server 172.28.xx.xx -User username -Password password

#Select the cluster from which the resource pool need to be selected. '*' represents all. Replace it with the resource pool name to be specific

$rpools = Get-ResourcePool -Location *

#Select each resource pool from the cluster

foreach($rpool in $rpools)
{
if($rpool.Name -ne 'Resources')
   {
    $rpoolc = $rpool.ExtensionData.Vm.count
       if($rpoolc -lt n )
#Replace 'n' with a number       
      {
      Write-Host "Number of Vms in Resource pool $($rpool) are $($rpoolc)" 
      }
   }
}

Comments

Popular posts from this blog

VMware and Windows Interview Questions: Part 2

VMware and Windows Interview Questions: Part 3

VMware vMotion error at 14%