PowerShell: XenServer Count Function



I’ve been hesitant to dive into XenServer PowerShell cmdlets, but there’s no rational reason to not do it. Citrix continues to make great strides in expanding and updating PowerShell for XenServer, PVS, and XenDesktop. Today, we’ll go over a function that queries an array of XenServer 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 XenServer 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

XenServer 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 :). 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 XenServer 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 XenServer connection, otherwise, the script will not know what pool master to query. The NoWarnNewCertificates flag prevents a prompt asking you to accept the new XenServer certificate (you can leave this out if you want this additional warning to let you know you’re connecting to a new XenServer).

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 XenServer 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 XenServer and go to the next one.

The results…

XenServer VM Count
--------- --------
XenServerPool1 108
XenServerPool2 109

You can get this and so much more from my github.

Thanks for reading,
Alain Assaf


RTP PowerShell User Group: Adding Scheduled Jobs to your PowerShell Toolbox – July 25th.

July 25th, the Research Triangle PowerShell User Group will host Jeff Hicks. He will cover implementing PowerShell scripts with Scheduled Jobs. It proves to be an informative meeting. Check more at MeetUp – http://meetu.ps/e/Fynqw/z9BYg/d



PowerShell: Friday Script Blitz 3



Happy 2018!!! In my current position I’m getting to do a lot of PowerShell scripting. Typically these are quick scripts for maintenance or finding information about our Citrix environment. I’m posting several here to share.

NOTE: These scripts were written against a XenApp 7.9/PVS 7.15 environment


If you have to maintain unique personality strings on your provisioned devices, then this script will help. It spits out all the strings in a PVS farm. I wrote this script due to a requirement with Symantec AV that expects to see a unique hardware ID for servers connecting to it. One way to do this in provisioned environments is with a startup script. See How to prepare Symantec Endpoint Protection clients on virtual disks for use with Citrix Provisioning Server for more info.

Get it from GitHub


The companion script for above. This script will set the Personality String for a PVS Device. It can take an input or generate one automatically. It assumes a 32 character hexadecimal string.

Get it from GitHub

Thanks for reading,