Hi Everyone, as promised last week on the @xdtipster twitter feed, here is the detailed blog on how to create HDX Policies through PoSH.

I suppose the first thing to note is that Citrix HDX Policies can be managed through PoSH in both XD5.x and XD7.x. What makes this possible is the Citrix Group Policy PoSH provider which was first introduced in XD5.

By default, once the Citrix snap-ins are loaded (asnp citrix*)  you will be able to view this provider and the associated drives using Get-PSProvider:

Click on screenshot to view full image:

Notice that by default, you will have access to two Citrix Group Policy PoSH Drives:

1.LocalGPO (relates to the Local GPO object)

2.Templates (relates to the Templates tab under the Policy node in Citrix Studio – applicible to XD7.x only btw)

Running Get-PSDrive will return a little more information about the drives themselves…

Click on screenshot to view full image:

To access one of these default drives all you have to do is change directory into the drive itself e.g. CD Templates:

Once at the root of the drive you can then view the existing data structure, amend existing objects or create new objects but more about that later…

I’ve been looking at this over the last week and the first question I asked myself when looking at the available PoSH Drives through the Citrix Group Policy provider was “Why do we not mount the DomainGPO object or the Policies object in the DB by default?”, to me they would be two of the most usefull drives to map right.  To be honest, I actually wondered if they were even available to mount at all…

Well after a bit of trial and error I figured out that they can indeed be mounted and that the’re is in fact a very good reason for not mounting them by default. Turns out that this is for scalabilty reasons in heavy scripting environments where delays may be encountered connecting to AD and or a Controller.

So how do we create a new PoSH drive and mount either the DomainGPO or Policies DB object? Creating a new PoSH drive is the easy part of course as there are plenty of instructions online and the help file for New-PSDrive steps through the process quite clearly. The harder part is figuring out exactly what parameters to use to mount the above mentioned objects.

This was a little tricky but during my investigations I found that once inside one of the Citrix Group Policy drives I could run the Help New-PSDrive -Full command and it would show me exactly how to create a new PSDrive using the available Citrix Objects:

Click on screenshot to view full image:

As you can see, based on the help output, the full list of available objects (Data structures) to mount to a drive include:



3.Controller (site Policy DB object)

4.Templates (HDX Poliocy Templates object)

Note: The FarmGPO option is not valid (legacy option only valid for XenApp)

As an example you could use the following command to create a new PoSH drive called XDPOL which points to a Controller and in turn the Policies object in the DB:

New-PSDrive -Name XDPOL -PSProvider CitrixGroupPolicy -Root \ -Controller DC1

Click on screenshot to view full image:

To view existing data stored in the new PSDrive run cd xdpol: and hit return and use the dir and cd commands to drill down into the data structure:

Click on screenshot to view full image:

From here you can create your site policies through PoSH using a combination of various commands i.e. cd, dir, New-Item, Set-ItemProperty…


Step 1: Create a new policy object using New-Item -Name (why not XDTipster…):

Click on screenshot to view full image:

Step 2: Enable Local App Access by using the Set-ItemProperty cmdlet with the Path, Name & Value parameters as can be seen below:

Click on screenshot to view full image:

Step 3: Refresh Citrix Studio to view the newly created HDX site based policy:

Click on screenshot to view full image:


To create a new PoSH drive and mount the DomainGPO object to manage AD based HDX policies through PoSH run the following command:

New-PSDrive -Name XDGPO -PSProvider CitrixGroupPolicy -Root \ -DomainGPO <String i.e. name of GPO object>

Best Regards
Mick Glover (aka XD Tipster)
Senior Readiness Specialist, Worldwide Support Readiness [EMEA]
Citrix Systems, Inc