Documenting a Citrix XenApp 6 Farm with Microsoft PowerShell

Even though Policies is next in the DSC, I will save that for last because of the sheer number of policy settings. So the next node we will do is Servers.

#servers
$servers = Get-XAServer -EA 0 | sort-object FolderPath, ServerName

If( $? )
{
	line 0 ""
	line 0 "Servers:"
	ForEach($server in $servers)
	{
		line 1 "Name: " $server.ServerName
		line 2 "Product: " $server.CitrixProductName -NoNewLine
		line 0 ", " $server.CitrixEdition -NoNewLine
		line 0 " Edition"
		line 2 "Version: " $server.CitrixVersion
		line 2 "Service Pack: " $server.CitrixServicePack
		line 2 "Operating System Type: " -NoNewLine
		If($server.Is64Bit)
		{
			line 0 "64 bit"
		}
		Else
		{
			line 0 "32 bit"
		}
		line 2 "TCP Address: " $server.IPAddresses
		line 2 "Logon: " -NoNewLine
		If($server.LogOnsEnabled)
		{
			line 0 "Enabled"
		}
		Else
		{
			line 0 "Disabled"
		}
		line 2 "Product Installation Date: " $server.CitrixInstallDate
		line 2 "Operating System Version: " $server.OSVersion -NoNewLine
		line 0 " " $server.OSServicePack
		line 2 "Zone: " $server.ZoneName
		line 2 "Election Preference: " $server.ElectionPreference
		line 2 "Folder: " $server.FolderPath
		line 2 "Product Installation Path: " $server.CitrixInstallPath
		If($server.LicenseServerName)
		{
			line 2 "License Server Name: " $server.LicenseServerName
			line 2 "License Server Port: " $server.LicenseServerPortNumber
		}
		If($server.ICAPortNumber -gt 0)
		{
			line 2 "ICA Port Number: " $server.ICAPortNumber
		}
		If($server.RDPPortNumber -gt 0)
		{
			line 2 "RDP Port Number: " $server.RDPPortNumber
		}
		#applications published to server
		$Applications = Get-XAApplication -ServerName $server.ServerName -EA 0 | sort-object FolderPath, DisplayName
		If( $? -and $Applications )
		{
			line 2 "Published applications:"
			ForEach($app in $Applications)
			{
				line 0 ""
				line 3 "Display name: " $app.DisplayName
				line 3 "Folder path: " $app.FolderPath
			}
		}
		#Citrix hotfixes installed
		$hotfixes = Get-XAServerHotfix -ServerName $server.ServerName -EA 0 | sort-object HotfixName
		If( $? -and $hotfixes )
		{
			line 0 ""
			line 2 "Citrix Hotfixes:"
			ForEach($hotfix in $hotfixes)
			{
				line 0 ""
				line 3 "Hotfix: " $hotfix.HotfixName
				line 3 "Installed by: " $hotfix.InstalledBy
				line 3 "Installed date: " $hotfix.InstalledOn
				line 3 "Hotfix type: " $hotfix.HotfixType
				line 3 "Valid: " $hotfix.Valid
				line 3 "Hotfixes replaced: "
				ForEach($Replaced in $hotfix.HotfixesReplaced)
				{
					line 4 $Replaced
				}
			}
		}
		line 0 ""
		Write-Output $global:output
		$global:output = $null
	}
}
Else
{
	line 0 "Server information could not be retrieved"
}
$servers = $null
$global:output = $null

Script output:

Servers:

Name: XA6
Product: Citrix Presentation Server, Platinum Edition
Version: 6.0.6410
Service Pack: 0
Operating System Type: 64 bit
TCP Address: 192.168.1.151
Logon: Enabled
Product Installation Date: 08/07/2011 17:38:43
Operating System Version: 6.1.7601 Service Pack 1
Zone: Default Zone
Election Preference: MostPreferred
Folder: Servers
Product Installation Path: C:\Program Files (x86)\Citrix\
License Server Name: XA6
License Server Port: 27000
ICA Port Number: 1494
Published applications:
Display name: Paint
Folder path: Applications/Graphic Apps
Citrix Hotfixes:
Hotfix: XA600W2K8R2X64012
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:31:03
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64017
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:20:08
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64018
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:31:59
Hotfix type: Hotfix
Valid: False
Hotfixes replaced:
XA600W2K8R2X64003

Hotfix: XA600W2K8R2X64021
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:32:34
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64026
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:33:09
Hotfix type: Hotfix
Valid: False
Hotfixes replaced:
XA600W2K8R2X64001
XA600W2K8R2X64011
XA600W2K8R2X64016
XA600W2K8R2X64025

Hotfix: XA600W2K8R2X64029
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:21:45
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64046
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:33:42
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64003
XA600W2K8R2X64018

Hotfix: XA600W2K8R2X64058
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:23:27
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64036

Hotfix: XA600W2K8R2X64060
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:34:19
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64002

Hotfix: XA600W2K8R2X64062
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:28:33
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64063
Installed by: XA6\Administrator
Installed date: 08/13/2011 18:34:57
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:

Hotfix: XA600W2K8R2X64068
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:30:15
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64019
XA600W2K8R2X64028
XA600W2K8R2X64043
XA600W2K8R2X64045
XA600W2K8R2X64047
XA600W2K8R2X64056
XA600W2K8R2X64061

Hotfix: XA600W2K8R2X64077
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:33:20
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64001
XA600W2K8R2X64011
XA600W2K8R2X64013
XA600W2K8R2X64016
XA600W2K8R2X64025
XA600W2K8R2X64026
XA600W2K8R2X64030
XA600W2K8R2X64040
XA600W2K8R2X64048

Hotfix: XA600W2K8R2X64079
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:34:14
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
XA600W2K8R2X64010
XA600W2K8R2X64034
XA600W2K8R2X64057

Hotfix: XA600W2K8R2X64089
Installed by: XA6\Administrator
Installed date: 09/28/2011 19:35:17
Hotfix type: Hotfix
Valid: True
Hotfixes replaced:
,

About Carl Webster

Webster is an independent consultant in the Nashville, TN area and specializes in Citrix, Active Directory and Exchange. 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 Farm with Microsoft PowerShell”

  1. 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

  2. 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

  3. 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

Trackbacks/Pingbacks

  1. Documenting a Citrix XenApp 6 Farm with Microsoft PowerShell « Roshan Ratnayake – Solution Architect - December 22, 2011

    [...] Awesome Script to document XenApp 6 Farm.. Read the full story here :http://carlwebster.com/documenting-a-citrix-xenapp-6-farm-with-microsoft-powershell/ [...]

Leave a Reply