I need something simple.
I have the command Get-HVMachineSummary. I need the "-state" parameter to get more than one value. ie: I need to see the vms that are in AVAILABLE or PROVISIONED state and count them.
I tried something with the command below
(Get-HVMachineSummary -PoolName $pool -state (PROVISIONED or AVAILABLE)).count
When you use the State parameter, you can only specify one value.
But you can get all states and then filter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Something is not correct ...
PS C:\> (Get-HVMachineSummary -PoolName $pool).count
337
PS C:\> Get-HVMachineSummary -PoolName $pool -State PROVISIONED
Machine DesktopPool DNS Name User Host Agent Datastore Status
------- ----------- -------- ---- ---- ----- --------- ------
evvdi012345678 VMWFULL08 evvdi0208... intra... px64vibm602.... {VMAX09... PROVISIONED
evvdi023456789 VMWFULL08 evvdi0208... intra... xvw036.df.in... VDI-HCI... PROVISIONED
evvdi034567891 VMWFULL08 evvdi0208... intra... xvw049.df.in... VDI-HCI... PROVISIONED
evvdi045678912 VMWFULL08 evvdi0208... intra... px64vibm403.... VMAX09L... PROVISIONED
evvdi056789123 VMWFULL08 evvdi0208... intra... xvw045.df.in... VDI-HCI... PROVISIONED
evvdi067891234 VMWFULL08 evvdi0208... intra... xvw041.df.in... VDI-HCI... PROVISIONED
evvdi089456123 VMWFULL08 evvdi0208... intra... xvw026.df.in... VDI-HCI... PROVISIONED
PS C:\> (Get-HVMachineSummary -PoolName $pool | where { 'PROVISIONED' -contains $_.State }).count
0
My bad, that should probably be $_.Status instead of $_.State
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Tanks LucD !!! I found the error. Follow the command
(Get-HVMachineSummary -PoolName $pool | where { 'PROVISIONED','AVAILABLE' -contains $_.Base.BasicState }).count