Documenting a Citrix XenApp 6 Farm with Microsoft PowerShell

A customer site I was at recently needed their new XenApp 6 farm documented. I remembered reading about Citrix having some PowerShell “stuff” for XenApp 6 so I started searching. I came across a short article by Michael Bogobowicz Getting a Farm Inventory With XenApp 6 PowerShell Scripting. That short article really piqued my interest. I took Michael’s little script as the starting point to learn Microsoft’s PowerShell. With some help from PowerShell MVP and fellow CTP Brandon Shell and a lot of help from Exchange MVP Michael B. Smith, I turned the original script into over 1600 lines of PowerShell to thoroughly document a XenApp 6 farm.

NOTE: This script is continually updated.  You can always find the most current version by going to http://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/

This article will focus only on XenApp 6. There will be additional articles for XenApp 5 and XenApp 6.5.

The prerequisites to follow along with this article are:

  • A server, physical or virtual, running Microsoft Windows Server 2008 R2 with or without SP1
  • Citrix XenApp 6 installed

In this article, we will be installing:

  • Citrix XenApp 6 Software Developers Kit (SDK)
  • Citrix Group Policy PowerShell Commands

My initial goal was to see if I could walk down the nodes in the Delivery Services Console (Figure 1), or AppCenter (the current Citrix terminology), and see if I could document every nook and cranny.

Figure 1

Before we can start using PowerShell to document anything in the XenApp 6 farm we first need to install the SDK and Citrix Group Policy commands. From your XenApp 6 server, go to http://tinyurl.com/XenApp6PSSDK (Figure 2).

Figure 2

Scroll down and click on Download XenApp 6 Powershell SDK — Version 6.1.2 (Figure 3). Do not exit your Internet browser at this time.

Figure 3

Extract the file to C:\XA6SDK. Click Start, Run, type in C:\XA6SDK\XASDK6.0.exe and press Enter (Figure 4).

Figure 4

Click Run (Figure 5).

Figure 5

Select I accept the terms of this license agreement and click Next (Figure 6).

Figure 6

Select Update the execution policy (to AllSigned) and Click Next (Figure 7).

Note: If you do not update the execution policy to AllSigned, the Citrix supplied XenApp PowerShell scripts will not load.

Figure 7

Click Install (Figure 8).

Figure 8

After a few seconds, the installation completes. Click Finish (Figure 9).

Figure 9

Back in your Internet browser; go to http://tinyurl.com/XenApp6PSPolicies (Figure 10).

Figure 10

Scroll down and click on Citrix.GroupPolicy.Commands.psm1 (Figure 11).

Figure 11

Save the file in two different places:

C:\Windows\System32\WindowsPowerShell\v1.0\Modules, in a new folder named Citrix.GroupPolicy.Commands (Figure 12)

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules, in a new folder named Citrix.GroupPolicy.Commands (Figure 13)

Figure 12

Figure 13

You can now close your Internet browser.

You now have two new Start Menu items under All Programs, Citrix:

    • Windows PowerShell with Citrix XenApp Server SDK (x86) (Figure 14)
    • Windows PowerShell with Citrix XenApp Server SDK (Figure 15)

Figure 14

Figure 15

The one shown in Figure 15 is 64-bit and will be the one we use for this article. Click Start, All Programs, Citrix, XenApp Server SDK, Windows PowerShell with Citrix XenApp Server SDK. You should see the message shown in Figure 16 .

Figure 16

This message is asking if you want to trust the PowerShell scripts from Citrix. Type the letter A and press Enter. You will see the Citrix PowerShell scripts and modules load (Figure 17).

Figure 17

To prepare for processing the Citrix farm policies, type in import-module Citrix.GroupPolicy.Commands, press Enter, type the letter A and press Enter (Figure 18).

Figure 18

,

About Carl Webster

Webster is a Sr. Solutions Architect for Choice Solutions, LLC and specializes in Citrix, Active Directory and Technical Documentation. Webster has been working with Citrix products for many years starting with Multi-User OS/2 in 1990.

View all posts by Carl Webster

14 Responses to “Documenting a Citrix XenApp 6 Farm with Microsoft PowerShell”

  1. Rohit Says:

    Hi Carl,
    Do you have some script for multiple Citrix farm report (Multiple DC and Farms)
    If XenApp5 and XenApp6 can be included would be great.

    Many Thanks
    Rohit

    Reply

  2. Ismael Says:

    Carl, i am having an issue running the application part of the script. here is an example of part of the script (like you need that) and then after is the error im getting… Any assistance would be greatly appreciated….

    $Applications = Get-XAApplication -EA 0 | sort-object FolderPath, DisplayName

    If( $? -and $Applications)
    {
    line 0 “”
    line 0 “Applications:”
    ForEach($Application in $Applications)
    {
    $AppServerInfoResults = $False
    $AppServerInfo = Get-XAApplicationReport -BrowserName $Application.BrowserName -EA 0
    If( $? )
    {
    $AppServerInfoResults = $True
    }
    $streamedapp = $False
    If($Application.ApplicationType -Contains “streamedtoclient” -or $Application.ApplicationType -Contains “streamedtoserver”)
    {

    ERROR:
    The term ‘line’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli
    ng of the name, or if a path was included, verify that the path is correct and try again.
    At I:\PowerShell\Citrix\Scripts\XenAppApplications.ps1:5 char:9
    + line <<<< 0 ""
    + CategoryInfo : ObjectNotFound: (line:String) [], CommandNotFoundException

    Reply

    • Carl Webster Says:

      WOW, that is an extremely old version of the script. Why are you not using the most current version?

      http://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/

      This function should be at the top of your script file.

      Function line
      #function created by Michael B. Smith, Exchange MVP
      [email protected] on Twitter
      #http://TheEssentialExchange.com
      {
      Param( [int]$tabs = 0, [string]$name = ’’, [string]$value = ’’, [string]$newline = “`n”, [switch]$nonewline )

      While( $tabs –gt 0 ) { $global:output += “`t”; $tabs–; }

      If( $nonewline )
      {
      $global:output += $name + $value
      }
      Else
      {
      $global:output += $name + $value + $newline
      }
      }

      Webster

      Reply

  3. Felton Lewis Says:

    Carl –

    Really great work! Thank you so much for this. I’m new to PowerShell so just the baby steps of going through this has been very helpful. I do have a question. I ran your XA6_Inventory_V4_Signed.ps1 script against one of my farms an it reported that a HFX was missing – (XA600R02W2K8R2X64015 Not Installed). So I installed the HFX and re-ran the script but the Word doc still shows that the HFX was not installed even though my DSC shows that it is. Am I missing something?

    Reply

    • Carl Webster Says:

      Ahhh, thanks for finding this bug. I believe I have it fixed and have sent you a script to test and verify.

      Thanks

      Webster

      Reply

  4. Craig Says:

    Hey Carl. This is seriously handy – im loving your work and i am learning so much from your scripting.

    thanks a bunch

    Reply

  5. Chaitanyakumar G Says:

    Hi Carl, I know you on internet in twitter, this site etc… this documentation is really very useful thanks a lot for posting it..

    Chaitanya.

    Reply

  6. Ismael Says:

    Hi Carl,

    I have been learning so much from your notes.

    How can I print this one? I would like to read it on the train…

    Thanks, Ismael

    Reply

  7. Sreekanth Says:

    WOW!!! Carl!!!

    Your scripts are amazing, keep up the great work!!!

    And by the by is there anyway we can only export the “ACTIVE” settings of XenApp6.5 each Policies to XL sheet or HTML?

    Once again its really great article, keep writing..!!!

    regards,
    Sreekanth

    Reply

    • Carl Webster Says:

      Sreekanth,

      Thanks for the kind words.

      I do think there is a simple change you can make to the Get-CtxGroupPolicy funcrion in the Citrix provided psm1 file.

      Take this section:

      foreach ($pol in $pols)
      {
      $props = CreateDictionary
      $props.PolicyName = $pol.Name
      $props.Type = $poltype
      $props.Description = $pol.Description
      $props.Enabled = $pol.Enabled
      $props.Priority = $pol.Priority
      CreateObject $props $pol.Name
      }

      and change it to this:

      foreach ($pol in $pols)
      {
      If($pol.Enabled)
      {
      $props = CreateDictionary
      $props.PolicyName = $pol.Name
      $props.Type = $poltype
      $props.Description = $pol.Description
      $props.Enabled = $pol.Enabled
      $props.Priority = $pol.Priority
      CreateObject $props $pol.Name
      }
      }

      I believe that will do what you are asking for.

      Thanks

      Webster

      Reply

  8. Tom K. Says:

    Wow. I worked alongside the article for the first pages and was having success in my own environment as I tried to duplicate the sample pieces of posh code. A good way to learn, but then I looked ahead and upon seeing the sheer amount of code-yet-to-come I jumped to the last page and was relieved to see it had been all put together and made available for donwload.

    Not being a coder or developer by nature or proefession I am always looking for examples I can emulate and hopefully learn from,but in this case I was going to be happy if I could download some or all of this and just have it handy. I can’t tell you though how amazed I was when the entire final script with all of those components contained within ran the first time I tried it in my environment on a XA6 server with the SDK installed. It’s never that easy, at least never has been before when I’ve copied other’s scripts. This is a testament to Mr. Webster’s attention to detail and thoroughness. Thanks man.

    Reply

Leave a Reply