|

Citrix: Backup your Citrix policies with the SDK and Powershell

I had to create a script to backup the Citrix policies, in order to do this I had to use the Citrix.GroupPolicy.Commands.psm1. Before I could use them I had to install the XenApp SDK, because I had to run this script from every Citrix XA server I wanted to create an unattended install of the SDK.  I added a zipfile with the extracted XASD60.exe here.

 

To install the SDK unattended you case use the following command line:

msiexec /i %systemdrive%:\XASDK60\XASDK6.0\Setup\Citrix.Common.Commands.Install_x64.msi /qn
msiexec /i %systemdrive%\XASDK60\XASDK6.0\Setup\Citrix.XenApp.Commands.Install_x64.msi /qn
msiexec /i %systemdrive%\XASDK60\XASDK6.0\Setup\Citrix.XenApp.Server.SDK_x64.msi /qn
msiexec /i %systemdrive%\XASDK60\XASDK6.0\Setup\XenAppGpmx_x64.msi /qn

After the installation of the SDK you should import the Citrix.GroupPolicy.Commands.psm1 by using:

# Set execution Policy

Set-ExecutionPolicy Unrestricted -force

#Import Module

Import-Module “C:\xenapp 6.5\Citrix.GroupPolicy.Commands.psm1”

Based on the way you arranged your policies you can choose the way you backup your policies as stated in CTX128625

 

Exporting from IMA Datastore Farm Policy

Unless a PowerShell drive is specified, the Export-CtxGroupPolicy cmdlet defaults the the IMA Datastore Farm Policy. To export from the IMA Datastore run the command:

Export-CtxGroupPolicy <PathToExportFolder>

Importing to IMA Datastore Farm Policy

Unless a PowerShell drive is specified, the Import-CtxGroupPolicy cmdlet defaults the the IMA Datastore Farm Policy. To export from the IMA Datastore run the command:

Import-CtxGroupPolicy <PathToExportFolder>

Exporting from Local Server Policy

Unless a PowerShell drive is specified, the Export-CtxGroupPolicy cmdlet defaults the the IMA Datastore Farm Policy. To export from the local server policy run the command:

Export-CtxGroupPolicy –DriveName localgpo <PathToExportFolder>

Importing to Local Server Policy

Unless a PowerShell drive is specified, the Import-CtxGroupPolicy cmdlet defaults the the IMA Datastore Farm Policy. To import to the local server policy, run the command:

Import-CtxGroupPolicy <PathToExportFolder> –DriveName localgpo

Exporting from Active Directory GPO

  • Associate a new PowerShell drive to the GPO to be exported. In this example, replace <DomainGpoDrv> with the name of the new PowerShell drive being created and replace <DomainGPO> with the name of the GPO being exported.
    New-PSDrive -Name <DomainGpoDrv> -PSProvider CitrixGroupPolicy –Root \ -DomainGpo <DomainGPO>
  • Export the GPO to a folder:
    Export-CtxGroupPolicy -DriveName <DomainGPODrv> <PathToExportFolder> 

Importing to Active Directory GPO

  • Associate a new PowerShell drive to the GPO to be exported. In this example, replace <DomainGpoDrv> with the name of the new PowerShell drive being created and replace <DomainGPO> with the name of the GPO being exported. Note: The target GPO must already exist in the Active Directory domain.
    New-PSDrive -Name <DomainGpoDrv> -PSProvider CitrixGroupPolicy –Root \ -DomainGpo <DomainGPO>
  • Import the GPO from a folder:
    Import-CtxGroupPolicy <PathToExportFolder> -DriveName <DomainGPODrv>

In my case it would be the following script:

# Set execution Policy

Set-ExecutionPolicy Unrestricted -force

#Import Module

Import-Module “C:\xenapp 6.5\Citrix.GroupPolicy.Commands.psm1”

#Backup policy

Export-CtxGroupPolicy “C:\xenapp 6.5\backup”

You could store the backup (XML files) to a remote location if you want to. Andrew Morgan did some magic in Powershell to integrate this into one script and a blog will follow soon on his website, I will update this blogpost once it’s posted.

Get new posts by email

One email when a new post goes up. Nothing else.

I only use your address to send new posts, and every email has an unsubscribe link. See the privacy policy.

ShareLinkedInXEmail
Kees Baggerman

Kees Baggerman

Senior Technical Director at Nutanix · NVIDIA Enterprise Platform Advisor · Former Citrix CTP · 15+ years in EUC

Kees Baggerman is Senior Technical Director, Performance & Solutions Engineering R&D at Nutanix, where he leads a global team responsible for defining how enterprise applications are delivered on the Nutanix platform. An NVIDIA Enterprise Platform Advisor since 2017 and a former Citrix Technology Professional, he has spent 15+ years driving EUC strategy and technical direction across architecture, product, and customer success. He has been writing here since 2011, sharing what he learns at the intersection of platform engineering and enterprise IT.

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.