• Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell and Word – Version 3.1

    The script to Document a Citrix XenApp 6.5 Farm with Microsoft PowerShell was originally written in October of 2011. The script was updated to Version 2 on January 21, 2013 and then updated to Version 3 on January 28, 2013. Since Version 3 was released, several issues have been reported and fixed. This article documents the fixes in Version 3.1.

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

    • Several typos were fixed to get rid of my southern drawl. No more “gettin”, “settin” or “runnin”.
    • More Write-Verbose statements were added.
    • Fixed all the issues reported by running the script with Set-StrictMode –Version 2.0 set.
    • For some users, when Microsoft Word is installed, the HKCU:\Software\Microsoft\Office\Common\UserInfo\CompanyName registry key is set and for some, it is not set. For those users, the HKCU:\Software\Microsoft\Office\Common\UserInfo\Company registry key is set. The script will now check both locations.
    • Some companies do not install the Microsoft Word Templates. This cause the Cover Page and Table of Contents sections of the script to generate numerous errors. The script now checks to see if the appropriate Word Template file is loaded successfully. If not, then the Cover Page and Table of Contents are skipped. The rest of the report is generated.
    • Pat Coughlin showed me how to disable Spell Check and Grammar Check while the document is created. For large XenApp 6.5 Farms, this can substantially speed up the document creation. For those large farms that can generate 1000+ page documents, Word would crash trying to keep track of all the spelling and grammar errors.
    • In the Load Evaluator section, the Load Throttling and Server User load settings were added.
    • A user on StackOverflow.com showed me how to indent the Table used for the Citrix Services.
    • Now that I know how to indent the Word Tables, I added Tables for the Citrix Installed Hotfixes and the Microsoft Hotfixes.
    • The Table for the Microsoft Hotfixes now lists all the Citrix recommended Microsoft hotfixes and whether the hotfix is Installed or Not Installed.
    • Before getting information on the Citrix Services and hotfixes, the server is tested to make sure it is reachable.
    • I received a question as to whether Microsoft Word needed to be installed to create the Word document. The script now verifies that Word is installed. If not, a warning is given and the script exits. (Figure 1 below)
    • I received reports of the script “crashing” if Word was running before the script was run. The script will now check to see if Word is running and if it is, the script will exit. If the script is run from a XenApp server, the script gets the Session ID of the user running the script. Then the script checks if the WinWord process is running in that session. If it is, a warning is given and the script exits. (Figure 2 below)
    • If remoting is not being used by running the Set-XADefaultComputerName cmdlet then the script cannot be run from a Session-only Host. The script will give a warning and exit. (Figure 3 below)

    How to use this script?

    I saved the script as XA65_Inventory_V31.ps1 in the C:\PSScripts folder. From the PowerShell prompt, change to the C:\PSScripts folder, or the folder where you saved the script. From the PowerShell prompt, type in:

    .\XA65_Inventory_V31.ps1 and press Enter.

    Running the script with –verbose, gives information of the script’s running.

    .\xa65_inventory_v31.ps1 -CompanyName "The Accidental Citrix Admin" -CoverPage "Whisp" -UserName "Amalgamated Consulting Group" -verbose
    

    Sample output showing remoting from a Session-only host.

    PS C:\webster> .\xa65_inventory_v31.ps1 -CompanyName "The Accidental Citrix Admin" -CoverPage "Whisp" -UserName "Amalgamated Consulting Group" -verbose
    VERBOSE: Remoting is enabled to XenApp server XA651
    VERBOSE: Getting Farm data
    VERBOSE: Connecting to computer XA651
    VERBOSE: Setting up Word
    VERBOSE: Create Word comObject.  If you are not running Word 2007, ignore the next message.
    VERBOSE: The object written to the pipeline is an instance of the type "Microsoft.Office.Interop.Word.ApplicationClass"
     from the component's primary interop assembly. If this type exposes different members than the IDispatch members,
    scripts written to work with this object might not work if the primary interop assembly is not installed.
    VERBOSE: Running Microsoft Word 2013
    VERBOSE: Validate company name
    VERBOSE: Validate cover page
    VERBOSE: Company Name: The Accidental Citrix Admin
    VERBOSE: Cover Page  : Whisp
    VERBOSE: User Name   : Amalgamated Consulting Group
    VERBOSE: Farm Name   : WebstersLab
    VERBOSE: Title       : Inventory Report for the WebstersLab Farm
    VERBOSE: Filename    : C:\webster\WebstersLab.docx
    VERBOSE: Load Word Templates
    VERBOSE: Create empty word doc
    VERBOSE: disable spell checking
    VERBOSE: insert new page, getting ready for table of contents
    VERBOSE: table of contents
    VERBOSE: set the footer
    VERBOSE: get the footer and format font
    VERBOSE: Footer text
    VERBOSE: add page numbering
    VERBOSE: return focus to main document
    VERBOSE: move to the end of the current document
    VERBOSE: Processing Configuration Logging
    VERBOSE: Connecting to computer XA651
    VERBOSE: Processing Administrators
    VERBOSE: Connecting to computer XA651
    VERBOSE: Processing Applications
    VERBOSE: Connecting to computer XA651
    VERBOSE: Connecting to computer XA651
    VERBOSE: Processing Configuration Logging/History Report
    VERBOSE: ParameterSet = ByConnectionString
    VERBOSE: Processing Load Balancing Policies
    VERBOSE: Connecting to computer XA651
    WARNING: Load balancing policy information could not be retrieved
    VERBOSE: Processing Load Evaluators
    VERBOSE: Connecting to computer XA651
    VERBOSE: Processing Servers
    VERBOSE: Connecting to computer XA651
    VERBOSE: Connecting to computer XA651
    VERBOSE: Testing to see if XA651 is online and reachable
    VERBOSE: XA651 is online.  Citrix Services and Hotfix areas processed.
    VERBOSE: Processing Citrix services for server XA651
    VERBOSE: Create Word Table for Citrix services
    VERBOSE: add Citrix services table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix services to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Get list of Citrix hotfixes installed
    VERBOSE: Connecting to computer XA651
    VERBOSE: number of hotfixes is 1
    VERBOSE: Create Word Table for Citrix Hotfixes
    VERBOSE: add Citrix installed hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix installed hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: compare Citrix hotfixes to recommended Citrix hotfixes from CTX129229
    VERBOSE: Processing Microsoft hotfixes for server XA651
    VERBOSE: Create Word Table for Microsoft Hotfixes
    VERBOSE: add Microsoft hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Microsoft hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Connecting to computer XA651
    VERBOSE: Testing to see if XA652 is online and reachable
    VERBOSE: XA652 is online.  Citrix Services and Hotfix areas processed.
    VERBOSE: Processing Citrix services for server XA652
    VERBOSE: Create Word Table for Citrix services
    VERBOSE: add Citrix services table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix services to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Get list of Citrix hotfixes installed
    VERBOSE: Connecting to computer XA651
    VERBOSE: number of hotfixes is 2
    VERBOSE: Create Word Table for Citrix Hotfixes
    VERBOSE: add Citrix installed hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix installed hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: compare Citrix hotfixes to recommended Citrix hotfixes from CTX129229
    VERBOSE: Processing Microsoft hotfixes for server XA652
    VERBOSE: Create Word Table for Microsoft Hotfixes
    VERBOSE: add Microsoft hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Microsoft hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Connecting to computer XA651
    VERBOSE: Testing to see if XA653 is online and reachable
    VERBOSE: XA653 is online.  Citrix Services and Hotfix areas processed.
    VERBOSE: Processing Citrix services for server XA653
    VERBOSE: Create Word Table for Citrix services
    VERBOSE: add Citrix services table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix services to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Get list of Citrix hotfixes installed
    VERBOSE: Connecting to computer XA651
    VERBOSE: number of hotfixes is 1
    VERBOSE: Create Word Table for Citrix Hotfixes
    VERBOSE: add Citrix installed hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix installed hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: compare Citrix hotfixes to recommended Citrix hotfixes from CTX129229
    VERBOSE: Processing Microsoft hotfixes for server XA653
    VERBOSE: Create Word Table for Microsoft Hotfixes
    VERBOSE: add Microsoft hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Microsoft hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Connecting to computer XA651
    VERBOSE: Testing to see if XA654 is online and reachable
    VERBOSE: XA654 is online.  Citrix Services and Hotfix areas processed.
    VERBOSE: Processing Citrix services for server XA654
    VERBOSE: Create Word Table for Citrix services
    VERBOSE: add Citrix services table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix services to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Get list of Citrix hotfixes installed
    VERBOSE: Connecting to computer XA651
    VERBOSE: number of hotfixes is 1
    VERBOSE: Create Word Table for Citrix Hotfixes
    VERBOSE: add Citrix installed hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Citrix installed hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: compare Citrix hotfixes to recommended Citrix hotfixes from CTX129229
    VERBOSE: Processing Microsoft hotfixes for server XA654
    VERBOSE: Create Word Table for Microsoft Hotfixes
    VERBOSE: add Microsoft hotfix table to doc
    VERBOSE: format first row with column headings
    VERBOSE: Move table of Microsoft hotfixes to the right
    VERBOSE: return focus back to document
    VERBOSE: move to the end of the current document
    VERBOSE: Processing Worker Groups
    VERBOSE: Connecting to computer XA651
    VERBOSE: Connecting to computer XA651
    VERBOSE: Connecting to computer XA651
    VERBOSE: Processing Zones
    VERBOSE: Connecting to computer XA651
    VERBOSE: Connecting to computer XA651
    WARNING: Remoting is enabled.
    WARNING: The Citrix.GroupPolicy.Commands module does not work with Remoting.
    WARNING: Citrix Policy documentation will not take place.
    VERBOSE: Finishing up Word document
    VERBOSE: Set Cover Page Properties
    VERBOSE: Update the Table of Contents
    VERBOSE: Save and Close document and Shutdown Word
    PS C:\webster>
    

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

    Copies of all the Cover Pages can be found here:

    Word 2007

    Word 2010

    Word 2013

    A word about Word

    1. Word must be installed
    2. After installation, Word should be opened, at least once, before you run the script
    3. It is better to do File, Options, OK before running the script

    The script does very strange things if the last two items are not done.  All kinds of errors are generated by the script if Word has not been opened at least once (Figure 4 below).  The second time the script is run (without Word haven been opened), fewer errors are generated.  The third time the script is run, it runs without errors.

    Word 2013 is the worst.  If Word 2013 is installed and never opened before running the script, a popup box is shown asking to set file extension defaults.  It does not matter if Never ask me again is selected and Yes or No is clicked, the popup box will return until Word 2013 is opened and closed.

    I am assuming there are registry keys and values that need to be set for the Word comObject to operate properly.

    Bottom Line: If you just installed Word, open Word and close Word before running the script.

    Figure 1 Word Not Installed
    Figure 1 Word Not Installed
    Figure 2 Word Already Running
    Figure 2 Word Already Running
    Figure 3 Running on a Session-only Host Error
    Figure 3 Running on a Session-only Host Error
    Figure 4 Word Not Opened Before Running the Script
    Figure 4 Word Not Opened Before Running the Script

    If you find any issues with the script, please send an email to Webster@carlwebster.com.

    At this time, the script still does not support non-English versions of Microsoft Word.  I am working on a fix for that.

    Thanks

    Webster

    , , ,

    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

    7 Responses to “Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell and Word – Version 3.1”

    1. Florian Kirchner Says:

      Really cool script. It saves me a lot time documenting XenApp environments. Thank You!

      Reply

    2. Jim Millard Says:

      As with the previous iterations: this script helps me provide delivery documentation to the customer in trivially-short order, and by “leaving it behind,” the customer is able to regenerate documentation as the environment evolves.

      Reply

    3. Jason Benway Says:

      Thank you for this script. It has saved me time documenting the environment and I can run it every few months and compare the word docs to see what has changed.

      Reply

    4. Brian Says:

      I am running into another type of error, I was able to successfully change the set-xadefaultcomputername to my controller and the script started to run but I am seeing this different error:

      The term ‘?_.SessionId’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check th
      e spelling of the name, or if a path was included, verify that the path is correct and try again.
      At C:\citrix\XA65_Inventory_V31.ps1:172 char:68
      + [bool]$wordrunning = ((Get-Process ‘WinWord’ -ea 0)|?{?_.SessionId <<<< -eq $SessionID}) -ne $null
      + CategoryInfo : ObjectNotFound: (?_.SessionId:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

      Any advice?

      Thanks again

      Reply

      • Carl Webster Says:

        What I have seen is that for some people, the “-” (dash), “_” (underscore), double-quote and single-quote marks get garbled and turned into look alike characters. I have had to use a text editor (Notepad, NotePad++) to do a Search and Replace for the weird characters and replace them with what they should be.

        Hope that helps

        Webster

        Reply

    5. Ben Says:

      Hi Webster,

      Great script!
      Thx for sharing

      However, one small remark: the link to the sample report is not working.
      It reads https://dl.dropbox.com/u/43555945/WebstersLab.docS
      Where it should read https://dl.dropbox.com/u/43555945/WebstersLab.docX
      The last one works when changed manually 🙂

      Again, great work
      Ben

      Reply

    Leave a Reply