Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell and Word – Version 3.1 Reviewed by Momizat on . 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 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 Rating:

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

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.

  • 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> 

I have placed an unsigned copy of this script at https://dl.dropbox.com/u/43555945/XA65_Inventory_V31.ps1

I have also placed a copy of the script with a TXT extension at https://dl.dropbox.com/u/43555945/XA65_Inventory_V31.txt

I have placed a digitally signed copy of this script at https://dl.dropbox.com/u/43555945/XA65_Inventory_V31_Signed.ps1

I have also placed a copy of the digitally signed script with a TXT extension at https://dl.dropbox.com/u/43555945/XA65_Inventory_V31_Signed.txt

ReadMe file is here https://dl.dropbox.com/u/43555945/XA65_InventoryReadMe.rtf

Sample report is here https://dl.dropbox.com/u/43555945/WebstersLab.docx

Copies of all the Cover Pages can be found here:

https://dl.dropbox.com/u/43555945/Word2007SampleCoverPages.zip

https://dl.dropbox.com/u/43555945/Word2010SampleCoverPages.zip

https://dl.dropbox.com/u/43555945/Word2013SampleCoverPages.zip

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

You just finished reading Documenting a Citrix XenApp 6.5 Farm with Microsoft PowerShell and Word – Version 3.1 on Carl Webster. Please consider leaving a comment!

Carl Webster
citrix

© 2014 lucadonettidontin.it | support.lucadonettidontin.it | lucadonettidontin.it/Blog