Create Citrix Policies with powershell XenDesktop 7.X

Website Visitors:

Citrix policies with powershell:

If you want to create multiple policies with lot of settings, that would be a difficult task for administrators while doing it manually. Studio is not that fast while responding to each setting. So, it would take lot of time and effort in doing it. How about automating policies creation task? Lets see how we can do it.
  • Download and install latest citrix scout. I did not provide scout link as it might change time to time. So, search on internet for latest scout link and download scout to your citrix delivery controller.
  • Extract contents to a folder. Open powershell and navigate to that folder.
  • Whatever path you extract this scout folder to, it has the folder structure like SOMEFOLDER\Scout\Current\Utilities\Citrix.GroupPolicy.Commands.psm1 Example, import-module "C:\temp\Scout\Current\Utilities\Citrix.GroupPolicy.Commands.psm1"
  • Let´s check if it is loaded:

ModuleType Version Name ExportedCommands ———- ——- —- —————- Script 0.0 Citrix.GroupPolicy.Commands {Add-CtxGroupPolicyFilter, Export-CtxGroupPolicy, Get-CtxG Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con Manifest Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…}

  • Now let´s check what commands are available:
get-command -Module Citrix.GroupPolicy.Commands

CommandType Name ModuleName ———– —- ———- Function Add-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands Function Export-CtxGroupPolicy Citrix.GroupPolicy.Commands Function Get-CtxGroupPolicy Citrix.GroupPolicy.Commands Function Get-CtxGroupPolicyConfiguration Citrix.GroupPolicy.Commands Function Get-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands Function Import-CtxGroupPolicy Citrix.GroupPolicy.Commands Function New-CtxGroupPolicy Citrix.GroupPolicy.Commands Function Remove-CtxGroupPolicy Citrix.GroupPolicy.Commands Function Remove-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands Function Set-CtxGroupPolicy Citrix.GroupPolicy.Commands Function Set-CtxGroupPolicyConfiguration Citrix.GroupPolicy.Commands Function Set-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands

  • We need to create a new PSdrive before we can move on:
new-psdrive -name LocalFarmGpo -psprovider CitrixGroupPolicy -controller localhost \

Name Used (GB) Free (GB) Provider Root CurrentLocation —- ——— ——— ——– —- ————— LocalFa CitrixGrou LocalFarmGpo:</span>

You should name it exactly like shown above (LocalFarmGpo) because for some reason all the functions in the PSM1 module are hardcoded to that PSDrive. Otherwise you will get errors. Here´s the link to the online documentation:

  • Use Get-PSDrive command to check if it is created successfully.
  • Now we can check how to create a new Citrix policy:
get-help New-CtxGroupPolicy


SYNOPSIS Creates group policies.

SYNTAX New-CtxGroupPolicy [-PolicyName] <String> [-Type] <String> [-Description <String>] [-Enabled <Boolean>] [-Priority <Int32>] [-DriveName <String>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION This cmdlet creates group policies using the Citrix.Common.GroupPolicy provider.

RELATED LINKS Set-CtxGroupPolicy Remove-CtxGroupPolicy

REMARKS To see the examples, type: “get-help New-CtxGroupPolicy -examples”. For more information, type: “get-help New-CtxGroupPolicy -detailed”. For technical information, type: “get-help New-CtxGroupPolicy -full”. For online help, type: “get-help New-CtxGroupPolicy -online”.

  • If you are successful so far, you are ready to create new citrix policy or add or remove settings from existing policy. To create new policy,
New-CtxGroupPolicy Test-Policy user
  • Diving into it:
cd LocalFarmGpo:\

We can now jump into user or computer settings.

Set-CtxGroupPolicyConfiguration Test-Policy user SessionClipboardWriteAllowedFormats Enabled

If you only want to see the settings for a specific Policy you can run:

Get-CtxGroupPolicyConfiguration Test-Policy -ConfiguredOnly

If you want to know all the settings you can set, run the following command:

  • To add settings to an existing policy,

Set-CtxGroupPolicyConfiguration Test-Policy user SessionClipboardWriteAllowedFormats Enabled

Use Get-CtxGroupPolicyConfiguration to see all settings. Note that if you have/know a policy in citrix studio, which is "Allow Bidirectional Content Redirection", when you use it with powershell, use it without quotes. Thats the only point to note. Now you can create multiple settings to an existing policy.

Want to learn more on Citrix Automations and solutions???

Subscribe to get our latest content by email.

If you like our content, please support us by sponsoring on GitHub below: