• Moving Citrix XenApp & XenDesktop Policies Quickly

    by  • July 11, 2015 • PowerShell, Scripting, XenApp, XenDesktop • 1 Comment

    In large environments, oftentimes there can be lots of Citrix Policies involved. The XenApp 6.5 and XenDesktop 7.x Studio and AppCenter consoles currently do not have an easy mechanism to move policies around quickly. This, however, can be easily accomplished by the use of PowerShell. The process for moving policies quickly in PowerShell is as follows:

     

    XenApp 6.5

    1. Install the XenApp 6.5 SDK from https://www.citrix.com/downloads/xenapp/sdks/powershell-sdk.html 
    2. Download the Citrix Group Policy Commandlets (Here).
    3. Start Powershell
    4. Type the command Set-ExecutionPolicy Unrestricted
    5. Type the command Import-Module C:\Scripts\Citrix.GroupPolicy.Commands.psm1 (Replace C:\Scripts\ with the location where you downloaded the Commandlets above)
    6. Now we can change the priority of policies on-the-fly by running the command Set-CtxGroupPolicy “Policy name” -Type type -Priority “Priority number”

    -Replace Policy Name with the name of the policy. This should be in quotes.

    -Replace type with either user or computer depending on the policy type.

    -Replace Priority number with the number of priority to give that policy. Remember that lower numbered policies take precedence over competing higher numbered policies.

     

    XenDesktop 7.x

    Strangely enough, I found that while XenDesktop 7.x Controllers have the SDK installed by default and there is no need to install additional commandlets, the process for making changes to policies is a little tougher as it requires mounting the policies as a PSDrive. The process is as follows:

    1. Open a PowerShell window on a Controller (DDC). You may want to run it as an administrator to avoid potential issues with permissions.

    2. Add the Citrix PoSh Commandlets by typing asnp Citrix* 

    3. Mount the Citrix Group Policy Provider by typing New-PSDrive XenPol -PSProvider CitrixGroupPolicy -root \ -Controller localhost

    4. Navigate to the mapped Policy provider CD XenPol:\User

    5. At this point you can type the dir command here and you will see your policies.

    6. Type Set-ItemProperty “Policy Name” Priority -Value Priority Number

    -Replace Policy Name with the name of the policy

    -Replace Priority Number with the number of priority to give that policy. Remember that lower numbered policies take precedence over competing higher numbered policies.

     

    One Response to Moving Citrix XenApp & XenDesktop Policies Quickly

    1. Daniel Drenski
      May 27, 2020 at 5:36 pm

      Very usefull article.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.