Hi
Usually to get the number of VM's in a pool I run this command:
Get-Pool | Select Pool_id, @{Name="NumVM";Expression={($_ | Get-DesktopVM).Count}} | out-gridview
But how can I list all pools and then select the pool which I want a count from?
Maybe something like:
Select 1 for Accounts
Select 2 for Marketing
and then count VM's just for that pool and out prompt where to output (Out-gridview or Export-CSV)
Thanks, Maelito
Hi LucD
I don't understand the line:
1..$pools.Count | %{
Write-Host "$_ " $Pools[$_ - 1].Name
Why do we need the 1..
Also is get-resourcepool the same as get-pool?
Thanks, Maelito
You mean something like this
$pools = Get-Pool
1..$pools.Count | %{
Write-Host "$_ " $Pools[$_ - 1].Pool_id
}
$number = Read-Host "Select a pool"
$pools[$number -1] | Select Pool_id,@{N="VM Count";E={@(Get-DesktopVM -Pool_id $_.Pool_id).Count}}
Updated: wrong code, updated now
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD
I don't understand the line:
1..$pools.Count | %{
Write-Host "$_ " $Pools[$_ - 1].Name
Why do we need the 1..
Also is get-resourcepool the same as get-pool?
Thanks, Maelito
Sorry about that, I initially gave the wrong code.
The updated code above is for a View environment.
The 1..$pools.Count part generates the numbers 1 till the number of pools you have.
The script loops over these numbers. Each number is displayed at the beginning of the line, together with the name of the pool.
This will allow you to make a selection of the pool.
Remember that an array is indexed starting at 0, so we have to subtract 1 to reference the correct entry in the array.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Brilliant, thanks!