Ever wondered how many VM’s you have on each Host? You could manually check it or then again you could let powershell do the work for you:
Get-VMHost | Select @{N=“Cluster“;E={Get-Cluster -VMHost $_}}, Name, @{N=“NumVM“;E={($_ | Get-VM).Count}} | Sort Cluster, Name | Export-Csv -NoTypeInformation c:\clu-host-numvm.csv
Sample Output:
Cluster | Name | NumVM |
CLUSTER1 | ESXH01.virtu-al.net | 12 |
CLUSTER1 | ESXH02.virtu-al.net | 5 |
CLUSTER1 | PRODESXH22.virtu-al.net | 6 |
CLUSTER1 | PRODESXH24.virtu-al.net | 11 |
CLUSTER1 | PRODESXH25.virtu-al.net | 19 |
CLUSTER1 | PRODESXH26.virtu-al.net | 14 |
Production Cluster | PRODESXH10.virtu-al.net | 2 |
Production Cluster | PRODESXH11.virtu-al.net | 7 |
Production Cluster | PRODESXH12.virtu-al.net | 8 |
Production Cluster | PRODESXH15.virtu-al.net | 22 |
Production Cluster | PRODESXH16.virtu-al.net | 16 |
Production Cluster | PRODESXH17.virtu-al.net | 31 |
Production Cluster | PRODESXH18.virtu-al.net | 24 |
Production Cluster | PRODESXH19.virtu-al.net | 27 |
DMZ Production Cluster | PRODESXH20.virtu-al.net | 21 |
DMZ Production Cluster | PRODESXH21.virtu-al.net | 27 |
Test Cluster | PRODESXH23.virtu-al.net | 4 |
Test Cluster | PRODESXH13.virtu-al.net | 8 |
Test Cluster | PRODESXH14.virtu-al.net |
Is there any script to automate ESXi HOST Patching?
to get VMs from cluster use this
get-cluster | Get-VM | Where-Object {$_.PowerState -eq “PoweredOn”} | Measure-Object
Ping it to the first host in the cluster then you always know where it is
hi all,
i am wondering if anyone here can help, i am after a script that give me VM name from window DNS name. for example i know the windows guest (DNS) name but want to find the VM for that in vmware.
Regards
TA
Need a script to search a set of hosts for a particular VM name and then power that VM on.
My VCenter is a VM. I have a case where I’ve got to shut the entire enviroment down and then power the enviroment back on. I’d like to script searching each host to find the VCenter server and then when it’s found power that VM on.
Any ideas?
Get-VMHost | Select @{N=”Cluster”;E={Get-Cluster -VMHost $_}}, Name, @{N=”NumVM”;E={($_ | Get-VM | where {$_.powerstate -eq “poweredon”}).Count}} | Sort Clu
ster, Name
Pingback: Count of powered-on VMs by host | VirtIRL
Excellent Alan.Super Post
Thanks a TON
i am looking for script to do the flowing
1-count how many linx,,windows,etc on each cluster
2- only powered on vm
Thanks
Pingback: PowerCLI: More One Liners « Virtu-Al
@Mike
My Fault, I didn’t make sure the results were always an array so the count didn’t work if it was 1, try this:
Get-VMHost | Select @{N=”Cluster”;E={Get-Cluster -VMHost $_}}, Name, @{N=”NumVM”;E={@($_ | Get-VM).Count}} | Sort Cluster, Name | Export-Csv -NoTypeInformation c:\clu-host-numvm.csv
For some reason this doesn’t work for hosts that have only one VM on them. The number of VMs in that case shows blank, as if there were no VMs at all on the host.
Is there a workaround?
Thanks
Thanks
@Kayser Soze
@utester12
Both answered here: http://www.virtu-al.net/2009/06/25/powercli-more-one-liners/
Thanks for the idea !
how can we extend this to get the templates as well
Thanks
How about listing the number of VMs per Resource Pool?
Thanks.
Oh to be using V2 ! Im still on V1 here, nice one though.
I replaced Export-Csv -NoTypeInformation c:\clu-host-numvm.csv
by Out-GridView looks great, cool script