There are times when you want to migrate a folder structure from one Citrix XenApp 6 farm to another.  For instance, if you maintain separate test, quality assurance, and production farms and need to migrate folders and applications between the farms.  Fortunately, this is super easy in XenApp 6 using PowerShell.

note Note: before you get started, be sure to check out [this post on how to install the Citrix XenApp 6 PowerShell Cmdlets]](/2010/08/02/how-to-install-the-citrix-xenapp-6-powershell-cmdlets/).

Export Specified Folders

You can export your entire folder structure, or just certain parts of it.  In the example below, I will export only the “Testing” folder (see the screen shot below).

Here is how to export just the “Testing” folder and its subfolders using PowerShell to a XML file called “TestingFolders.xml”:

Get-XAFolder -FolderPath "Applications/Testing" -Recurse | Export-Clixml c:\TestingFolders.xml

Explanation

Well, the cool thing about PowerShell is that it is pretty readable, so I don’t think this command needs a lot of explanation. However, let’s look at the resulting XML file.

  <s>Applications/Testing/Microsoft Office</s>
  <s>Applications/Testing/Sales</s>
  <s>Applications/Testing/Utilities</s>
  <s>Applications/Testing/Utilities/Microsoft</s>
  <s>Applications/Testing/Utilities/Citrix</s>

No rocket science there either. It is just a list of folders. You could easily hand craft one of these XML files to create a folder structure. What I am going to do here is modify the folder path so that the folders get created in the “Applications/QA” folder and then save the file as “QAfolders.xml”. Here is what the XML file looks like now:

  <s>Applications/QA/Microsoft Office</s>
  <s>Applications/QA/Sales</s>
  <s>Applications/QA/Utilities</s>
  <s>Applications/QA/Utilities/Microsoft</s>
  <s>Applications/QA/Utilities/Citrix</s>

Import Folders

Now that you have your XML file, it is relatively easy to import. Here is how to do it:

Import-Clixml c:\QAFolders.xml | New-XAFolder

Here are the results:

Next Steps

So all this folder structure stuff is fine, but wouldn’t it be nice to import some apps into those folders? Of course it would. Here is how to export and import XenApp 6 published applications using PowerShell.