I’ve been hesitant to dive into Citrix Hypervisor PowerShell cmdlets, but there’s no rational reason to not do it. Citrix continues to make great strides in expanding and updating PowerShell for its hypervisor, PVS, and XenDesktop. Today, we’ll go over a function that queries an array of Citrix Hypervisor Poolmasters and returns the total VM count on each. The idea behind this function was to stop manually counting VM’s in XenCenter and to understand VM growth and Citrix Hypervisor Pool utilization.

NOTE: Thanks to The Scripting Frog for getting me most of the way there with this function.

The manual count of VM’s

Citrix Hypervisor and PowerShell?

It may seem weird to use PowerShell to perform queries of a Linux-based system, but such is the world we live in. I remember back in my day :smile: Apple was a joke; IBM ruled the PC market and Linux didn’t exist. Of course, I still remember saving BASIC programs to a cassette deck.


The script will prompt for credentials which can be root or any Citrix Hypervisor administrator. Then you connect to each pool master in turn…

The important flags are -SetDefaultSession and -NoWarnNewCertificates. You must set the default session on each new Citrix Hypervisor connection, otherwise, the script will not know what pool master to query. The -NoWarnNewCertificates flag prevents a prompt asking you to accept the new Citrix Hypervisor certificate (you can leave this out if you want this additional warning to let you know you’re connecting to a new Citrix Hypervisor).

Unless you can refer to your XenServers with a DNS name, you can do some quick translation to make your output more readable. I’m using a switch statement to replace the IP address with a Citrix Hypervisor name.

The rest is just getting all the VM’s (minus snapshots, templates, etc.), counting them and putting the results into a custom PowerShell Object. Finally, you disconnect from each Citrix Hypervisor and go to the next one.

The results…

Citrix Hypervisor VM Count
XenServerPool1 108
XenServerPool2 109


I hope this post encourages you to leverage the PowerShell commands for Citrix Hypervisor. You can find the full function on my GitHub page.

Learning More

Value for Value

If you received any value from reading this post, please help by becoming a supporter.

Thanks for Reading, Alain Assaf