Documenting a Citrix Provisioning Services Farm with Microsoft PowerShell and Word – Version 4

November 2, 2013

PowerShell, PVS

Version 4 of the Citrix Provisioning Services script has been released.  Version4  adds several new features along with support for 11 language versions of Microsoft Word 2007, 2010 and 2013.  There is now a separate ReadMe file for the Version 4 script.

Before I get started listing all the new features and fixes, I want to start by thanking a dedicated and hardworking group of testers and others who provided PowerShell help and guidance for developing Version 4.

  • Christian Hackmann
  • Citrix Engineering Team
  • Claudio Rodrigues
  • David O’Brien
  • Eelco de Vries
  • Jarian Gibson
  • James Ma
  • Javier Sanchez Alcazar
  • Kees Baggerman
  • Markus Irmer
  • Markus Zehnle
  • Martin Therkelsen
  • Michael Rueefli
  • Mike Fry
  • Mike Nelson
  • Nick Cookendorfer
  • Olav Lillebo
  • Patrick Seymour
  • Roy Textor
  • Russell Fox
  • Shaun Ritchie
  • Thomas Daugaard
  • Vladimir Radojevic
  • Wilco van Bragt

I will create separate articles for most of the new features to keep this article from becoming a novel.  Here is a list of the new features, changes and fixes.

  • Add Appendix A and B for Server Advanced Settings information
  • Add detecting the running Operating System to handle Word 2007 oddness with Server 2003/2008 vs Windows 7 vs Server 2008 R2
  • Add elapsed time to end of script
  • Add get-date to all write-verbose statements
  • Add more Write-Verbose statements
  • Add option to SaveAs PDF
  • Add setting Default tab stops at 36 points (1/2 inch in the USA)
  • Add support for non-English versions of Microsoft Word
  • Add WMI hardware information for Computer System, Disks, Processor and Network Interface Cards
  • Change $Global: variables to regular variables
  • Change all instances of using $Word.Quit() to also use proper garbage collection
  • Change Default Cover Page to Sideline since Motion is not in German Word
  • Change Get-RegistryValue function to handle $null return value
  • Change wording when script aborts from a blank company name
  • Fix issues with Word 2007 SaveAs under (Server 2008 and Windows 7) and Server 2008 R2
  • Abort script if Farm information cannot be retrieved
  • Align Tables on Tab stop boundaries
  • Consolidated all the code to properly abort the script into a function AbortScript
  • Force the -verbose common parameter to be $True if running PoSH V3
  • General code cleanup
  • If cover page selected does not exist, abort script
  • If running Word 2007 and the Save As PDF option is selected then verify the Save As PDF add-in is installed.  Abort script if not installed.
  • Only process WMI hardware information if the server is online
  • Strongly type all possible variables
  • Verify the SOAP and Stream services are started on the server processing the script
  • Verify Word object is created.  If not, write error and suggestion to document and abort script

Appendix A and B will allow you to see the Advanced Settings for all PVS servers and verify they are configured correctly.

For some very large environments, the script can take hours, days or more than a week to run!  Some people are curious how long the script takes to run so I added an elapsed time at the very end of the script (where else?).

Also, for those where the script can take an extremely long time to run, they complained there wasn’t enough information being displayed in the PowerShell session to let them know if the script was running or hung.  I have added many more Write-Verbose statements and added the date and time to the beginning of each.

Saving as a PDF has been requested often.  In my lab, the PDF file can be 5x to 10x larger than the DOCX file.  If you are running Word 2007, you will need the Microsoft Save as PDF add-in.  Saving as PDF is disabled by default.

When versions of the various documentation scripts that created a Word document were released, it didn’t take but a few minutes before I heard from my French and German script users.  The scripts only worked on English versions of Word.  No more.  Version 4 supports 11 language versions of Microsoft Word.  The following languages are supported:

  • Catalan
  • Danish
  • Dutch
  • English
  • Finnish
  • French
  • German
  • Norwegian
  • Portuguese
  • Spanish
  • Swedish

There is now an optional parameter, -Hardware, that will provide hardware information on each PVS server.  This parameter is disabled by default.

The default Cover Page of Motion had to be changed to Sideline as Motion does not exist in German Word.  Since I have no idea what version of Word or what language version of Word you are using before the script starts, I have to detect if the default Cover Page Sideline was selected and then change it to the language specific name in the script.

If you are running PowerShell version 3 or 4, the $Verbose variable is set to $True automatically.  Therefore you are not required to use the -verbose switch to turn on the Write-Verbose statements.

I tried to strongly type as many variables as possible.  But the way Citrix implemented PowerShell for PVS made that quite a challenge.  Sometimes using strongly typed variables with the Citrix cmdlets made the script crash!  I had no issue with this with the other documentation scripts.

One of the problems with using PowerShell code from well known PowerShell gurus is they rarely use error-checking in their code.  I had issues that were found with some of the new testers.  “Things” that had always worked, no longer worked.  For example, creating the $Word variable using Word COMObject.  I had one tester where Word appeared to work fine but the script would not create the $Word variable.  It turned out to be a corrupt Word install on his computer.  He ran a repair of Word and then the script ran with no issues.  But what I really needed to do was add a test to make sure the $Word variable was successfully created and if not, abort the script.

This is just a very quick overview of some of the changes in Version 4 of the PVS script.  I will be writing separate articles to cover some of these changes in greater detail.

I hope you enjoy V4. You can download the scripts by going to this link.  http://carlwebster.com/where-to-get-copies-of-the-documentation-scripts/

Thanks

Webster

About Carl Webster

Webster is an independent consultant in the Nashville, TN area 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

One Response to “Documenting a Citrix Provisioning Services Farm with Microsoft PowerShell and Word – Version 4”

  1. LordXen Says:

    On XA6 I have these 2 errors with V4 :

    VERBOSE: 11/04/2013 12:19:17: Retrieving IMA Farm Policies
    The term ‘Get-CtxGroupPolicy’ is not recognized as the name of a cmdlet, function, script file, or ope
    eck the spelling of the name, or if a path was included, verify that the path is correct and try again
    At C:\Users\renaud.adm\Downloads\XA6_Inventory_V4_Signed.ps1:1369 char:33
    + $Policies = Get-CtxGroupPolicy <<<< -EA 0 | sort-object Type,Priority
    + CategoryInfo : ObjectNotFound: (Get-CtxGroupPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    WARNING: Citrix Policy information could not be retrieved.

    VERBOSE: 11/04/2013 12:19:25: Creating ADGpoDrv PSDrive
    New-PSDrive : A parameter cannot be found that matches parameter name 'DomainGpo'.
    At C:\Users\renaud.adm\Downloads\XA6_Inventory_V4_Signed.ps1:5127 char:79
    + New-PSDrive -Name ADGpoDrv -PSProvider CitrixGroupPolicy -Root \ -DomainGpo <<<< $($Ctx
    al" -EA 0 | out-null
    + CategoryInfo : InvalidArgument: (:) [New-PSDrive], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewPSDriveCommand

    WARNING: Company Citrix Servers is not readable by this XenApp 6.0 server
    WARNING: Company Citrix Servers was probably created by an updated Citrix Group Policy Provider

    In the report the Citrix policies does not appear and the AD policies are listed "that could not be processed"

    Reply

Leave a Reply

Current month ye@r day *