Recently I was asked if we could list some basic information from VMware View using the cmdlets which come installed on the View Administrator server, the request was specifically a list of VMs and the pool they were in, this was easily achieved with the Get-DesktopVM cmdlet as below:
Get-DesktopVM | Select Name, Pool_id | Sort Pool_id
Secondly they were after a list of pools and the number of VMs which were part of these pools, these can be found using a calculated property and a combination of the Get-Pool and Get-DesktopVM cmdlets as below:
Get-Pool | Select Pool_id, @{Name="NumVM";Expression={($_ | Get-DesktopVM).Count}}
I used this thanks to VMware Communities:
## get all pools, and for each, get the count of how many of their VMs are powered on
) | ?{$_.PowerState -eq “poweredOn”} | Measure-Object).Count} else {“no desktops found”}
## create new object with some info for PoolID and NumPoweredOnVMs
New-Object -Type PSObject -Property @{
PoolID = $strPoolID
NumPoweredOnVMs = $intNumPoweredOnVMs
} ## end new-object
} ## end foreach-object
} | Select PoolID, NumPoweredOnVMs
Another way to grab count of vm’s in a pool… only drawback is you will get a $null pool_id for any full server vm’s and replica’s
Get-DesktopVM | group Pool_ID | Select name, count
Pingback: Обзор блогов от 25/03/13 | vMind.ru