Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell

A customer site I was at recently needed their new XenApp 6.0 farm documented. I remembered reading about Citrix having some PowerShell “stuff” for XenApp 6.0 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 1800 lines of PowerShell to thoroughly document a XenApp 6 farm. For this article, I will update the original XenApp 6.0 documentation script for XenApp 6.5.

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.5. There are already articles for XenApp 5 and XenApp 6.0 available on my web site.

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.5 installed

The nice thing about XenApp 6.5 compared to both XenApp 5 and XenApp 6 is that all the basic Citrix PowerShell stuff is installed when you install XenApp 6.5. But we still need the XenApp 6.5 PowerShell Help and the Citrix Group Policy PowerShell Commands.

My initial goal was to see if I could walk down the nodes in the AppCenter (Figure 1) 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.5 farm we first need to install the SDK (for the Help file) and Citrix Group Policy commands. From your XenApp 6.5 server, go to http://tinyurl.com/XenApp65PSSDK (Figure 2).

Figure 2

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

Figure 3

Extract the file to C:\XA65SDK. Click Start, Run, type in C:\XA65SDK\XASDK6.5.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.

Click Start, Administrative Tools, Windows PowerShell Modules.

To prepare for processing the Citrix farm policies, type in import-module Citrix.GroupPolicy.Commands and press Enter.

,

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

48 Responses to “Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell”

  1. Rajib Chanda Says:

    getting this error

    PS C:\Users\TEMP> .\XA65_Inventory_V43.ps1
    VERBOSE: 08/13/2017 13:09:44: Testing output parameters
    VERBOSE: 08/13/2017 13:09:44: MSWord is set
    VERBOSE: 08/13/2017 13:09:44: CoName is
    Loading Windows PowerShell snap-in: Citrix.XenApp.Commands
    VERBOSE: 08/13/2017 13:09:44: Remoting is not being used
    VERBOSE: 08/13/2017 13:09:44: Getting initial Farm data
    WARNING: Farm information could not be retrieved
    C:\Users\TEMP\XA65_Inventory_V43.ps1 : Farm information could not be retrieved. Script cannot continue.
    At line:1 char:1
    + .\XA65_Inventory_V43.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,XA65_Inventory_V43.ps1

    Reply

    • Carl Webster Says:

      Are you running the script on a Data Collector?

      Webster

      Reply

      • Rajib Chanda Says:

        on a citrix test server

      • Carl Webster Says:

        Did you follow the instructions in the ReadMe file?

        Webster

      • Rajib Chanda Says:

        Yes sir, I followed the same…help to run that script

      • Carl Webster Says:

        On your test server, run a simple test. Start a PowerShell prompt and run the following commands:

        add-pssnapin *citrix*
        get-XAFarm

        What happens?

        Webster

      • Rajib Chanda Says:

        FarmName : OUP
        ServerVersion : 6.5.0
        AdministratorType : Full
        SessionCount : 6
        MachineName : GBOXFCTX06

      • Carl Webster Says:

        Apologies for the delayed response. It was Sunday and I actually took the day off the spend time with my wife and Simon and Sophie.

        If you are running the script on the same computer you ran this quick test on, then it should just work. THe script has several warnings built in. It will error out if the server is not a Collector or if Word is not installed or the required PowerShell snap-in is not installed.

        Webster

  2. Geir Says:

    Hi. I get a message saying. Max length of Server is 10.

    Reply

    • Carl Webster Says:

      Not a problem. Just a message I put in there for when the output was not coming up right. I’ll remove it if I ever update the script again.

      Webster

      Reply

  3. George Says:

    Dear Carl

    I admire your jod and thank you.

    Please at your first convenience help me on this.

    I am running the 4.1 version of your script under 6.5 Farm, PoSH v2 and Office 2010. Script seems to be running at the moment smooth but I wonder why I cannot see the document file created in any folder.

    Reply

    • Carl Webster Says:

      Try running in 32-bit PowerShell. Several people have reported this issue on several scripts but I have never been able to reproduce it.

      Webster

      Reply

  4. Victor Says:

    Hey Carl, Victor again… I was able to run it for couple of 6.5 farms without any issue. But then I tried to run it for a XA 5 Windows 2008 farm and I am simply getting this.

    I am Citrix administrator on that farm and I am able to run Discovery and all that stuff. Do you know more specifically what the issue might be with this? Ir there a workaround or this is just a no go for the XA 5.0?

    I am using the XA52008 script version 4.2 from your downloads page.

    C:\Victor Torres\Inventory\XenApp5_2008V4.2\XA52008_Inventory_V42.ps1 : Farm information could not be retrieved. Scrip
    t cannot continue.
    At line:1 char:28
    + .\XA52008_Inventory_V42.ps1 <<<<
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,XA52008_Inventory_V42.ps1

    Reply

    • Carl Webster Says:

      Did you read the ReadMe file for the 2008 script?

      If you go to a PoSH session, load the snapins and run Get-XAFarm, does it work? If not, not an issue with the script.

      Webster

      Reply

      • Victor Says:

        This is what I get when running Get-XAFarm

        I am administrator (both Citrix and local) and IMA is started, I suppose I will have to look into enabling remoting.

        Get-XAFarm Citrix commands must be executed at the Citrix server or using remoting. Make sure that your user account is a Citrix administrator and that the IMA service is started.

      • Carl Webster Says:

        Xenapp 5 cmdlets do not support remoting.

        Webster

  5. Victor Says:

    Hello everyone… first of all thank you very much for such wonderful job.

    Now I am not being able to run the script, I had to remove the first line which requires Powershell v3 because I cannot install v3 in the environment I am auditing. And I don’t know maybe I caused this issue but I am getting this… anyone else is having this issue?

    Unexpected token ‘4’ in expression or statement.
    At D:\Victor Torres\Inventory\XenApp65V4.25\XA65_Inventory_V42.ps1:5959 char:56
    + $ServerName = (Get-Childitem env:computername).value 4 <<<$Null
    + CategoryInfo : ParserError: (4:String) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

    Reply

    • Carl Webster Says:

      How did you edit the file? If you used Notepad you broke the file. The file has lots of foreign characters in it which is why line 2 says to not edit the file in an ASCII editor.

      The script can be run remotely. Can you not install PoSH V3 on a domain joined PC and run the script from there?

      Webster

      Reply

      • Victor Says:

        I edited with Notepad so I broke it… I read about PoSH V3 but I am auditing this environment which is pretty tight in resources and I am external consultant so not easy for me to get a test domain machine or server 🙁

        Thanks for your quick response Carl… again awesome job!

      • Carl Webster Says:

        Edit the original script with Wordpad and remove that line.

        Webster

      • Victor Says:

        Thanks Carl!… as soon as I replied this morning I got with the IT guy and luckily they did have a test machine available.

        I was able to run the script and it worked like a charm!!!

        IT LOOKS AWESOME!!!

        Thanks again!

  6. Patrick Dewey Says:

    Hello Carl,

    Well Citrix did it again and I cant find this link anymore..

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

    Any help that you can provide would be great.

    Reply

  7. int13 Says:

    i can confirm in my our new XA64 Farm with 140 Servers runs the script very slow after 2 Minutes. Now the script runs 26 Hours. I can see the script is slow by check the server status.

    Reply

    • int13 Says:

      ok, think i have an workaround for the slow issue on my system. When the script hangs on one server check, i start MS Word manuall an close word. Now the script run normal.

      Reply

    • slon842 Says:

      Hi,
      its strange but it was taking around 20 hours to scan 20 servers for me – so i have decided to run it as a scheduled task (run as my admin account) – which lead me to another problem causing the script to hangs on “loading word templates” verbose message – as a work around I’ve created Desktop directory according to this post (http://stackoverflow.com/questions/1674836/how-to-run-a-windows-2008-task-from-the-scheduler-with-interact-with-desktop) – so when i was finaly able to run it as a task it seems to work much faster when i’m not loged in than runing it from interactive console after loging to xenapp server….

      Reply

  8. Beat Says:

    Hi, I’m realy interested in your script. Issue now, the script is running about 2 hours and only one server is done. 🙁
    Is it normal that the script is running so slow?

    Reply

    • Carl Webster Says:

      What version of the script are you running?
      Did you run with -verbose?
      Are you running on a Controller or remotely?
      What version of Word? Word 2013 is 66% slower than Word 2007 and 40% slower than Word 2010.

      Thanks

      Webster

      Reply

      • Julien Says:

        I’m running in the same problem. The document generated is very good and I would love to schedule it on a weekly basis.
        The only problem, the script takes ages to execute, but not every time.
        Sometime it takes under 10 minutes, sometimes it takes 8 hours !
        I’m using the verbose mode with or without -hardware and -software switches regardless.
        I can see it’s very slow when it starts processing “Gather session sharing info for Appendix A”.
        I’m running the script directly on my Citrix XA 6.5 server with Office 2010 installed.
        Here’s a bit of the log when it starts to get slow:

        VERBOSE: 01/28/2014 10:38:05: Processing application
        VERBOSE: 01/28/2014 10:38:05: Gather session sharing info for Appendix A
        VERBOSE: 01/28/2014 10:38:09: Max length of server name is 15
        VERBOSE: 01/28/2014 10:39:07: Move table to the right
        VERBOSE: 01/28/2014 10:39:10: Return focus back to document
        VERBOSE: 01/28/2014 10:39:26: Move to the end of the current document
        VERBOSE: 01/28/2014 10:39:33: Processing application
        VERBOSE: 01/28/2014 10:39:33: Gather session sharing info for Appendix A
        VERBOSE: 01/28/2014 10:39:38: Max length of server name is 26
        VERBOSE: 01/28/2014 10:40:36: Move table to the right
        VERBOSE: 01/28/2014 10:40:40: Return focus back to document
        VERBOSE: 01/28/2014 10:40:56: Move to the end of the current document
        VERBOSE: 01/28/2014 10:40:57: Processing application
        VERBOSE: 01/28/2014 10:40:57: Gather session sharing info for Appendix A
        VERBOSE: 01/28/2014 10:41:02: Max length of server name is 26

        Thanks in advance for your help.

      • Carl Webster Says:

        I am aware of the issue. It has never happened to me on any of the hundreds of servers I have run the scripts on over the last three years. I have several reports of this slowness issue. I do plan on spending some time, eventually, on finding a solution. It would be nice to be able to get remote access into a server experiencing the issue and run ISE and step through the code at the slow points to see what is going on. Before the slow points the data has already been gathered and the table has been pre-created with the proper number of columns and rows. What happens next is just a simple loop that says place this piece of data from an array into this cell in the table. I have absolutely no idea why, for some people, that process can take minutes per cell.

        Thanks

        Webster

  9. Raju Says:

    I’m receiving the error below while running the script . XenApp 6.5 farm is built in windows 2012 AD.
    WARNING: XXXXXXX is not readable by this XenApp 6.5 server
    WARNING: XXXXXXX was probably created by an updated Citrix Group Policy Provider

    Reply

    • Carl Webster Says:

      That simply means that the AD Group Policy with the name “XXXXXXX” was created by a Citrix product that your installed Citrix XenApp 6.5 Group Policy Provider does not know how to handle. That could be a XenDesktop created policy for example.

      Webster

      Reply

  10. Leon Says:

    Carl,

    I was trawling the net trying to learn some PowerShell bit and bobs to help with a proof of concept deployment I am tinkering with when I came accross your scrpit. Wow!!! you blow my mind. I ran the script against my PoC and have ended up with a document that could form the basis of a build document for future deployments.

    I just wanted to right a note and say thankyou and very well done.

    It would be interesting if the output data could be fed into MS Visio to have it automate a drawing of an infrastructure, but that is way beyond my skills.

    Cheers

    Leon (UK)

    Reply

  11. Anand Says:

    Thanks for the outstanding effort Webster!

    Can we safely run the script in Powershell V3 environment without any caveats?

    Thank you

    Reply

    • Carl Webster Says:

      I don’t believe so. I believe there are a couple of issues running the script in V3. I have not tested any of my scripts with V3.

      Webster

      Reply

  12. Chris Says:

    Thank you Mr. Webster!

    I ran the following to append my Citrix Group Policy Settings to the file.

    Import-Module .\CitrixGPOPS\Citrix.GroupPolicy.Commands.psm1
    New-PSDrive -Name CitrixGPO -PSProvider CitrixGroupPolicy -Root \ -Domain “NAME OF GPO with CITRIX SETTINGS”
    Get-CTXGroupPolicy -PolicyName “*” -DriveName CitrixGPO |out-file .\XA65Farm.txt -append
    Get-CTXGroupPolicyConfiguration -PolicyName “*” -ConfiguredOnly -DriveName CitrixGPO |out-file .\XA65Farm.txt -append
    Remove-PSDrive -Name CitrixGPO

    Reply

  13. Andrew Says:

    Hi Carl,

    Great article and amazing script – thanks for your efforts!

    One question – when I run the script, it executes and runs to completion. When it processes the policies section, it only
    returns the unfiltered policies. We have our Citrix policies stored within group policy. I am running the script from one of our ZDC’s and am unsure where I should check…

    Reply

    • Carl Webster Says:

      The script can only process Citrix IMA based policies. I have not been able to figure out how to use the Citrix provided policy module to gather data on Active Directory based polcies.

      Webster

      Reply

  14. Aresh Says:

    This is by far the best thing i have seen around XenApp by an individual outside Citrix 🙂

    Cheers

    Reply

  15. Alex Says:

    Thanks a lot Carl. I had the same type of a complete inventory script built out for our 5.0 infrastructure, and in the process of looking for 6.5 updates stumbled on your script, and since it’s so complete I won’t even need to do much of an update.
    Thanks a lot
    Alex

    Reply

  16. Yannick Says:

    Many thanks. I was struggling with listing all the servernames of a workergroup and this helped!

    Reply

  17. Sean Says:

    Hi Carl,
    Thanks for this article and scripts, very, very useful.
    Sean

    Reply

  18. Graham Says:

    Awesome!

    Reply

  19. Scott Barnwell Says:

    An amazing find, thanks for publishing this. It has saved me a lot of time on my final documentation to the client. I had to right click the psm1 files, choose properties and press the unblock button in order for them to work. Also run Set-ExecutionPolicy RemoteSigned as well.

    Reply

  20. Adam B Says:

    Carl – Just wanted to say thank you very much for this article and your hard work. Much appreciated.

    Reply

  21. yonderbox Says:

    Wow, just wow.
    You did some heavy lifting, Carl.
    Congratulations and thank you.

    Reply

Leave a Reply