Documenting a Citrix Provisioning Services Farm with Microsoft PowerShell
A customer site I was at recently needed their Provisioning Services (PVS) farm documented. Since I had already created PowerShell scripts to document the various versions of XenApp, I figured a PVS script should be easy to create. I could not have been more wrong in my thinking! This article and script were written on and tested against PVS 5.6 SP2, 6.0 and 6.1 all running on Microsoft Windows Server 2008 R2 SP1.
NOTE: This script is continually updated. You can always find the most current version by going to https://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/
I would recommend downloading the Citrix PVS PowerShell Programmer’s Guide for the version of PVS for your Farm. While most of each guide is the same, each guide is specific to each version of PVS. For example, the PVS 6.1 guide has information on the new Personal vDisk that is only supported in PVS 6.1.
My initial goal was to see if I could walk down the nodes in the Provisioning Services Console (PSC) and see if I could document every nook and cranny. PVS 5.6 SP2 is shown in Figure 1 and PVS 6.1 is shown in Figure 2.
Before we can start using PowerShell to document anything in the PVS farm we first need to register the PVS Console PowerShell snap-in. Even if you are running PVS on a 64-bit Windows Server Operating System you must still register the snap-in with the 32-bit .Net Framework.
Change to the folder where the PSC is installed. By default, this is C:\Program Files\Citrix\Provisioning Services Console.
To register with the 32-bit .Net Framework, enter the following command (Figure 3):
To register with the 64-bit .Net Framework, enter the following command (Figure 4):
Click Start, Administrative Tools, Windows PowerShell Modules. A PowerShell session starts. Enter the following command:
Add-PSSnapin –Name McliPSSnapIn
Everything is now setup for us to get started.
PowerShell commands are supposed to be done in a Verb-Noun format. Get-Something, New-Something, Copy-Something, etc. That is the way Citrix did the PowerShell commands for XenApp 5, XenApp 6.x and XenDesktop 4. But that is not what Citrix did for PVS.
In XenApp or XenDesktop 4, if I wanted to retrieve farm information I would use Get-XAFarm or Get-XDFarm. I thought the obvious thing to do was to use Get-PVSFarm but that doesn’t work. For some bizarre reason, Citrix decided to wrap PowerShell around the PVS MCLI command line utilities.
I could write an article on all the things Citrix did wrong with their PVS PowerShell implementation but that would not serve any useful purpose. This article will do its best to stay focused on what is needed to use what Citrix gave us to document a PVS farm.
To get a list of the MCLI commands, showing just the Name, where the “verb” starts with “mcli”, type the following in the PowerShell session (results are shown in Figure 11):
Get-Command -Verb mcli | Select-Object Name