VMware Cloud Community
shinpad
Contributor
Contributor

List VMs with specific OS

can someone explain how to get a list and count of all my vms that are running windows?

thanks

0 Kudos
4 Replies
RvdNieuwendijk
Leadership
Leadership

You can get a list of all your virtual machines that are running Microsoft Windows with:

Get-VM | `
  Where-Object {$_.Guest.ExtensionData.GuestFamily -eq "windowsGuest"}

You can get the total number of virtual machines running Microsoft Windows with:

(Get-VM | `
  Where-Object {$_.Guest.ExtensionData.GuestFamily -eq "windowsGuest"} | `
  Measure-Object).Count

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
brentcochran
Enthusiast
Enthusiast

I'm sure the snazzy script provided by RvdNieuwendijk works great, but I would just download RVtools here: http://www.robware.net/.  I've found it to be really useful for several simple reporting scenarios.  DL, install, point it at your vCenter, done.

If you end up using/liking it, drop Rob a few bucks!  Smiley Happy

Thanks,

Brent

0 Kudos
shinpad
Contributor
Contributor

thanks to both of you.

the strange thing is that they both give different numbers of VMs!!!

Robert, does your script only list powered on machines?

0 Kudos
RvdNieuwendijk
Leadership
Leadership

My script lists powered off virtual machines as well. RVTools by default also lists templates. And my script doesn't list templates. Maybe that is the difference.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos