Professional Documents
Culture Documents
XA52008 Inventory V42
XA52008 Inventory V42
0
#This File is in Unicode format. Do not edit in an ASCII editor.
<#
.SYNOPSIS
Creates a complete inventory of a Citrix XenApp 5 for Windows Server 2008
farm using Microsoft Word 2010 or 2013.
.DESCRIPTION
Creates a complete inventory of a Citrix XenApp 5 for Windows Server 2008
farm using Microsoft Word and PowerShell.
Works for XenApp 5 Server 2008 32-bit and 64-bit
Creates either a Word document or PDF named after the XenApp 5 for Windows
Server 2008 farm.
Document includes a Cover Page, Table of Contents and Footer.
Version 4.xx includes support for the following language versions of
Microsoft Word:
Catalan
Danish
Dutch
English
Finnish
French
German
Norwegian
Portuguese
Spanish
Swedish
.PARAMETER CompanyName
Company Name to use for the Cover Page.
Default value is contained in
HKCU:\Software\Microsoft\Office\Common\UserInfo\CompanyName or
HKCU:\Software\Microsoft\Office\Common\UserInfo\Company, whichever is
populated on the
computer running the script.
This parameter has an alias of CN.
.PARAMETER CoverPage
What Microsoft Word Cover Page to use.
Only Word 2010 and 2013 are supported.
(default cover pages in Word en-US)
Valid input is:
Alphabet (Word 2010. Works)
Annual (Word 2010. Doesn't work well for this report)
Austere (Word 2010. Works)
Austin (Word 2010/2013. Doesn't work in 2013, mostly works in 2010 but
Subtitle/Subject & Author fields need to me moved after title box is moved up)
Banded (Word 2013. Works)
Conservative (Word 2010. Works)
Contrast (Word 2010. Works)
Cubicles (Word 2010. Works)
Exposure (Word 2010. Works if you like looking sideways)
Facet (Word 2013. Works)
Filigree (Word 2013. Works)
Grid (Word 2010/2013.Works in 2010)
Integral (Word 2013. Works)
Ion (Dark) (Word 2013. Top date doesn't fit, box needs to be manually
resized or font changed to 8 point)
Ion (Light) (Word 2013. Top date doesn't fit, box needs to be manually
resized or font changed to 8 point)
Mod (Word 2010. Works)
Motion (Word 2010/2013. Works if top date is manually changed to 36
point)
Newsprint (Word 2010. Works but date is not populated)
Perspective (Word 2010. Works)
Pinstripes (Word 2010. Works)
Puzzle (Word 2010. Top date doesn't fit, box needs to be manually
resized or font changed to 14 point)
Retrospect (Word 2013. Works)
Semaphore (Word 2013. Works)
Sideline (Word 2010/2013. Doesn't work in 2013, works in 2010)
Slice (Dark) (Word 2013. Doesn't work)
Slice (Light) (Word 2013. Doesn't work)
Stacks (Word 2010. Works)
Tiles (Word 2010. Date doesn't fit unless changed to 26 point)
Transcend (Word 2010. Works)
ViewMaster (Word 2013. Works)
Whisp (Word 2013. Works)
Default value is Sideline.
This parameter has an alias of CP.
.PARAMETER UserName
User name to use for the Cover Page and Footer.
Default value is contained in $env:username
This parameter has an alias of UN.
.PARAMETER PDF
SaveAs PDF file instead of DOCX file.
This parameter is disabled by default.
For Word 2007, the Microsoft add-in for saving as a PDF muct be installed.
For Word 2007, please see http://www.microsoft.com/en-
us/download/details.aspx?id=9943
The PDF file is roughly 5X to 10X larger than the DOCX file.
.PARAMETER MSWord
SaveAs DOCX file
This parameter is set True if no other output format is selected.
.PARAMETER Hardware
Use WMI to gather hardware information on: Computer System, Disks, Processor
and Network Interface Cards
This parameter is disabled by default.
.PARAMETER Software
Gather software installed by querying the registry.
Use SoftwareExclusions.txt to exclude software from the report.
SoftwareExclusions.txt must exist, and be readable, in the same folder as
this script.
SoftwareExclusions.txt can be an empty file to have no installed applications
excluded.
See Get-Help About-Wildcards for help on formatting the lines to exclude
applications.
This parameter is disabled by default.
.PARAMETER StartDate
Start date, in MM/DD/YYYY HH:MM format, for the Configuration Logging report.
Default is today's date minus seven days.
If the StartDate is entered as 01/01/2014, the date becomes 01/01/2014
00:00:00.
.PARAMETER EndDate
End date, in MM/DD/YYYY HH:MM format, for the Configuration Logging report.
Default is today's date.
If the EndDate is entered as 01/01/2014, the date becomes 01/01/2014
00:00:00.
.PARAMETER Summary
Only give summary information, no details.
This parameter is disabled by default.
This parameter cannot be used with either the Hardware, Software, StartDate
or EndDate parameters..EXAMPLE
PS C:\PSScript > .\XA52008_Inventory_V42.ps1
Will use all Default values and save the document as a PDF file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
Carl Webster for the Company Name.
Conservative for the Cover Page format.
Administrator for the User Name.
.EXAMPLE
PS C:\PSScript > .\XA52008_Inventory_V42.ps1 -Summary
Will use all Default values and add additional information for each server
about its hardware.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
Will use all Default values and add additional information for each server
about its installed applications.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
Will use all Default values and add additional information for each server
about its installed applications.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
Will use all Default values and add additional information for each server
about its installed applications.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
Will use:
Carl Webster Consulting for the Company Name.
Mod for the Cover Page format.
Carl Webster for the User Name.
.EXAMPLE
PS C:\PSScript .\XA52008_Inventory_V42.ps1 -CN "Carl Webster Consulting" -CP
"Mod" -UN "Carl Webster"
Will use:
Carl Webster Consulting for the Company Name (alias CN).
Mod for the Cover Page format (alias CP).
Carl Webster for the User Name (alias UN).
.EXAMPLE
PS C:\PSScript > .\XA52008_Inventory_V42.ps1 -Section Policies
Will use all Default values and save the document as a PDF file.
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\CompanyName="Carl
Webster" or
HKEY_CURRENT_USER\Software\Microsoft\Office\Common\UserInfo\Company="Carl
Webster"
$env:username = Administrator
#thanks to @jeffwouters and Michael B. Smith for helping me with these parameters
[CmdletBinding(SupportsShouldProcess = $False, ConfirmImpact = "None",
DefaultParameterSetName = "Word") ]
Param(
[parameter(ParameterSetName="Word",Mandatory=$False)]
[Switch]$MSWord=$False,
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Switch]$PDF=$False,
[parameter(Mandatory=$False)]
[Switch]$Hardware=$False,
[parameter(Mandatory=$False)]
[Switch]$Software=$False,
[parameter(Mandatory=$False)]
[Datetime]$StartDate = ((Get-Date -displayhint date).AddDays(-7)),
[parameter(Mandatory=$False)]
[Datetime]$EndDate = (Get-Date -displayhint date),
[parameter(Mandatory=$False)]
[Switch]$Summary=$False,
[parameter(Mandatory=$False)]
[Switch]$AddDateTime=$False,
[parameter(Mandatory=$False)]
[string]$Section="All",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CN")]
[ValidateNotNullOrEmpty()]
[string]$CompanyName="",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("CP")]
[ValidateNotNullOrEmpty()]
[string]$CoverPage="Sideline",
[parameter(ParameterSetName="Word",Mandatory=$False)]
[parameter(ParameterSetName="PDF",Mandatory=$False)]
[Alias("UN")]
[ValidateNotNullOrEmpty()]
[string]$UserName=$env:username
Set-StrictMode -Version 2
#force on
$PSDefaultParameterValues = @{"*:Verbose"=$True}
$SaveEAPreference = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'
If(!(Test-Path Variable:MSWord))
{
$MSWord = $False
}
If(!(Test-Path Variable:PDF))
{
$PDF = $False
}
If(!(Test-Path Variable:Hardware))
{
$Hardware = $False
}
If(!(Test-Path Variable:Software))
{
$Software = $False
}
If(!(Test-Path Variable:StartDate))
{
$StartDate = ((Get-Date -displayhint date).AddDays(-7))
}
If(!(Test-Path Variable:EndDate))
{
$EndDate = ((Get-Date -displayhint date))
}
If(!(Test-Path Variable:Summary))
{
$Summary = $False
}
If(!(Test-Path Variable:AddDateTime))
{
$AddDateTime = $False
}
If(!(Test-Path Variable:Section))
{
$Section = "All"
}
If($MSWord)
{
Write-Verbose "$(Get-Date): MSWord is set"
}
ElseIf($PDF)
{
Write-Verbose "$(Get-Date): PDF is set"
}
Else
{
$ErrorActionPreference = $SaveEAPreference
Write-Verbose "$(Get-Date): Unable to determine output parameter"
If($MSWord -eq $Null)
{
Write-Verbose "$(Get-Date): MSWord is Null"
}
ElseIf($PDF -eq $Null)
{
Write-Verbose "$(Get-Date): PDF is Null"
}
Else
{
Write-Verbose "$(Get-Date): MSWord is $($MSWord)"
Write-Verbose "$(Get-Date): PDF is $($PDF)"
}
Write-Error "Unable to determine output parameter. Script cannot continue"
Exit
}
$ValidSection = $False
Switch ($Section)
{
"Admins" {$ValidSection = $True}
"Apps" {$ValidSection = $True}
"ConfigLog" {$ValidSection = $True}
"Farm" {$ValidSection = $True}
"LoadEvals" {$ValidSection = $True}
"Policies" {$ValidSection = $True}
"Printers" {$ValidSection = $True}
"Servers" {$ValidSection = $True}
"Zones" {$ValidSection = $True}
"All" {$ValidSection = $True}
}
`t`tAdmins
`t`tApps
`t`tConfigLog
`t`tFarm
`t`tLoadEvals
`t`tPolicies
`t`tPrinters
`t`tServers
`t`tZones
`t`tAll
[int]$PointsPerTabStop = 36
[int]$Indent0TabStops = 0 * $PointsPerTabStop
[int]$Indent1TabStops = 1 * $PointsPerTabStop
[int]$Indent2TabStops = 2 * $PointsPerTabStop
[int]$Indent3TabStops = 3 * $PointsPerTabStop
[int]$Indent4TabStops = 4 * $PointsPerTabStop
# http://www.thedoctools.com/index.php?
show=wt_style_names_english_danish_german_french
[int]$wdStyleHeading1 = -2
[int]$wdStyleHeading2 = -3
[int]$wdStyleHeading3 = -4
[int]$wdStyleHeading4 = -5
[int]$wdStyleNoSpacing = -158
[int]$wdTableGrid = -155
#http://groovy.codehaus.org/modules/scriptom/1.6.0/scriptom-office-2K3-
tlb/apidocs/org/codehaus/groovy/scriptom/tlb/office/word/WdLineStyle.html
[int]$wdLineStyleNone = 0
[int]$wdLineStyleSingle = 1
[int]$wdHeadingFormatTrue = -1
[int]$wdHeadingFormatFalse = 0
Function GetComputerWMIInfo
{
Param([string]$RemoteComputerName)
[bool]$GotComputerItems = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName
win32_computersystem
}
Catch
{
$Results = $Null
}
ForEach($Item in $ComputerItems)
{
OutputComputerItem $Item
}
}
ElseIf(!$?)
{
Write-Verbose "$(Get-Date): Get-WmiObject win32_computersystem failed
for $($RemoteComputerName)"
Write-Warning "Get-WmiObject win32_computersystem failed for $
($RemoteComputerName)"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "Get-WmiObject win32_computersystem failed for
$($RemoteComputerName)" "" $Null 0 $False $True
WriteWordLine 0 2 "On $($RemoteComputerName) you may need to run
winmgmt /verifyrepository" "" $Null 0 $False $True
WriteWordLine 0 2 "and winmgmt /salvagerepository. If this is a
trusted Forest, you may" "" $Null 0 $False $True
WriteWordLine 0 2 "need to rerun the script with Domain Admin
credentials from the trusted Forest." "" $Null 0 $False $True
}
}
Else
{
Write-Verbose "$(Get-Date): No results returned for Computer
information"
If($MSWORD -or $PDF)
{
WriteWordLine 0 2 "No results returned for Computer information"
"" $Null 0 $False $True
}
}
[bool]$GotDrives = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName
Win32_LogicalDisk
}
Catch
{
$Results = $Null
}
[bool]$GotProcessors = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName
win32_Processor
}
Catch
{
$Results = $Null
}
#Get Nics
Write-Verbose "$(Get-Date): `t`t`tNIC information"
[bool]$GotNics = $True
Try
{
$Results = Get-WmiObject -computername $RemoteComputerName
win32_networkadapterconfiguration
}
Catch
{
$Results
}
If($GotNics)
{
ForEach($nic in $nics)
{
Try
{
$ThisNic = Get-WmiObject -computername
$RemoteComputerName win32_networkadapter | Where {$_.index -eq $nic.index}
}
Catch
{
$ThisNic = $Null
}
$Results = $Null
$ComputerItems = $Null
$Drives = $Null
$Processors = $Null
$Nics = $Null
}
Function OutputComputerItem
{
Param([object]$Item)
If($MSWord -or $PDF)
{
[System.Collections.Hashtable[]] $ItemInformation = @()
$ItemInformation += @{ Data = "Manufacturer"; Value =
$Item.manufacturer; }
$ItemInformation += @{ Data = "Model"; Value = $Item.model; }
$ItemInformation += @{ Data = "Domain"; Value = $Item.domain; }
$ItemInformation += @{ Data = "Total Ram"; Value = "$
($Item.totalphysicalram) GB"; }
$Table = AddWordTable -Hashtable $ItemInformation -Columns Data,Value
-List -AutoFit $wdAutoFitFixed;
$Table.Rows.SetLeftIndent($Indent2TabStops,$wdAdjustNone)
FindWordDocumentEnd
$Table = $Null
WriteWordLine 0 2 ""
}
}
Function OutputDriveItem
{
Param([object]$Drive)
If($MSWORD -or $PDF)
{
[System.Collections.Hashtable[]] $DriveInformation = @()
$DriveInformation += @{ Data = "Caption"; Value = $Drive.caption; }
$DriveInformation += @{ Data = "Size"; Value = "$($drive.drivesize)
GB"; }
If(![String]::IsNullOrEmpty($drive.filesystem))
{
$DriveInformation += @{ Data = "File System"; Value =
$Drive.filesystem; }
}
$DriveInformation += @{ Data = "Free Space"; Value = "$
($drive.drivefreespace) GB"; }
If(![String]::IsNullOrEmpty($drive.volumename))
{
$DriveInformation += @{ Data = "Volume Name"; Value =
$Drive.volumename; }
}
If(![String]::IsNullOrEmpty($drive.volumedirty))
{
If($drive.volumedirty)
{
$tmp = "Yes"
}
Else
{
$tmp = "No"
}
$DriveInformation += @{ Data = "Volume is Dirty"; Value = $tmp; }
}
If(![String]::IsNullOrEmpty($drive.volumeserialnumber))
{
$DriveInformation += @{ Data = "Volume Serial Number"; Value =
$Drive.volumeserialnumber; }
}
Switch ($drive.drivetype)
{
0 {$tmp = "Unknown"}
1 {$tmp = "No Root Directory"}
2 {$tmp = "Removable Disk"}
3 {$tmp = "Local Disk"}
4 {$tmp = "Network Drive"}
5 {$tmp = "Compact Disc"}
6 {$tmp = "RAM Disk"}
Default {$tmp = "Unknown"}
}
$DriveInformation += @{ Data = "Drive Type"; Value = $tmp; }
$Table = AddWordTable -Hashtable $DriveInformation -Columns Data,Value
-List -AutoFit $wdAutoFitContent;
$Table.Rows.SetLeftIndent($Indent2TabStops,$wdAdjustNone)
FindWordDocumentEnd
$Table = $Null
WriteWordLine 0 2 ""
}
}
Function OutputProcessorItem
{
Param([object]$Processor)
If($MSWORD -or $PDF)
{
[System.Collections.Hashtable[]] $ProcessorInformation = @()
$ProcessorInformation += @{ Data = "Name"; Value = $Processor.name; }
$ProcessorInformation += @{ Data = "Description"; Value =
$Processor.description; }
$ProcessorInformation += @{ Data = "Max Clock Speed"; Value = "$
($processor.maxclockspeed) MHz"; }
If($processor.l2cachesize -gt 0)
{
$ProcessorInformation += @{ Data = "L2 Cache Size"; Value = "$
($processor.l2cachesize) KB"; }
}
If($processor.l3cachesize -gt 0)
{
$ProcessorInformation += @{ Data = "L3 Cache Size"; Value = "$
($processor.l3cachesize) KB"; }
}
If($processor.numberofcores -gt 0)
{
$ProcessorInformation += @{ Data = "Number of Cores"; Value =
$Processor.numberofcores; }
}
If($processor.numberoflogicalprocessors -gt 0)
{
$ProcessorInformation += @{ Data = "Number of Logical
Processors"; Value = $Processor.numberoflogicalprocessors; }
}
Switch ($processor.availability)
{
1 {$tmp = "Other"}
2 {$tmp = "Unknown"}
3 {$tmp = "Running or Full Power"}
4 {$tmp = "Warning"}
5 {$tmp = "In Test"}
6 {$tmp = "Not Applicable"}
7 {$tmp = "Power Off"}
8 {$tmp = "Off Line"}
9 {$tmp = "Off Duty"}
10 {$tmp = "Degraded"}
11 {$tmp = "Not Installed"}
12 {$tmp = "Install Error"}
13 {$tmp = "Power Save - Unknown"}
14 {$tmp = "Power Save - Low Power Mode"}
15 {$tmp = "Power Save - Standby"}
16 {$tmp = "Power Cycle"}
17 {$tmp = "Power Save - Warning"}
Default {$tmp = "Unknown"}
}
$ProcessorInformation += @{ Data = "Availability"; Value = $tmp; }
$Table = AddWordTable -Hashtable $ProcessorInformation -Columns
Data,Value -List -AutoFit $wdAutoFitFixed;
$Table.Rows.SetLeftIndent($Indent2TabStops,$wdAdjustNone)
FindWordDocumentEnd
$Table = $Null
WriteWordLine 0 2 ""
}
}
Function OutputNicItem
{
Param([object]$Nic, [object]$ThisNic)
If($MSWORD -or $PDF)
{
[System.Collections.Hashtable[]] $NicInformation = @()
If($ThisNic.Name -eq $nic.description)
{
$NicInformation += @{ Data = "Name"; Value = $ThisNic.Name; }
}
Else
{
$NicInformation += @{ Data = "Name"; Value = $ThisNic.Name; }
$NicInformation += @{ Data = "Description"; Value =
$Nic.description; }
}
$NicInformation += @{ Data = "Connection ID"; Value =
$ThisNic.NetConnectionID; }
$NicInformation += @{ Data = "Manufacturer"; Value = $Nic.manufacturer;
}
Switch ($ThisNic.availability)
{
1 {$tmp = "Other"}
2 {$tmp = "Unknown"}
3 {$tmp = "Running or Full Power"}
4 {$tmp = "Warning"}
5 {$tmp = "In Test"}
6 {$tmp = "Not Applicable"}
7 {$tmp = "Power Off"}
8 {$tmp = "Off Line"}
9 {$tmp = "Off Duty"}
10 {$tmp = "Degraded"}
11 {$tmp = "Not Installed"}
12 {$tmp = "Install Error"}
13 {$tmp = "Power Save - Unknown"}
14 {$tmp = "Power Save - Low Power Mode"}
15 {$tmp = "Power Save - Standby"}
16 {$tmp = "Power Cycle"}
17 {$tmp = "Power Save - Warning"}
Default {$tmp = "Unknown"}
}
$NicInformation += @{ Data = "Availability"; Value = $tmp; }
$NicInformation += @{ Data = "Physical Address"; Value =
$Nic.macaddress; }
$NicInformation += @{ Data = "IP Address"; Value = $Nic.ipaddress; }
$NicInformation += @{ Data = "Default Gateway"; Value =
$Nic.Defaultipgateway; }
$NicInformation += @{ Data = "Subnet Mask"; Value = $Nic.ipsubnet; }
If($nic.dhcpenabled)
{
$DHCPLeaseObtainedDate =
$nic.ConvertToDateTime($nic.dhcpleaseobtained)
$DHCPLeaseExpiresDate =
$nic.ConvertToDateTime($nic.dhcpleaseexpires)
$NicInformation += @{ Data = "DHCP Enabled"; Value =
$Nic.dhcpenabled; }
$NicInformation += @{ Data = "DHCP Lease Obtained"; Value =
$dhcpleaseobtaineddate; }
$NicInformation += @{ Data = "DHCP Lease Expires"; Value =
$dhcpleaseexpiresdate; }
$NicInformation += @{ Data = "DHCP Server"; Value =
$Nic.dhcpserver; }
}
If(![String]::IsNullOrEmpty($nic.dnsdomain))
{
$NicInformation += @{ Data = "DNS Domain"; Value =
$Nic.dnsdomain; }
}
If($nic.dnsdomainsuffixsearchorder -ne $Null -and
$nic.dnsdomainsuffixsearchorder.length -gt 0)
{
[int]$x = 1
WriteWordLine 0 2 "DNS Search Suffixes`t:" -nonewline
$nicdnsdomainsuffixsearchorder = $nic.dnsdomainsuffixsearchorder
$tmp = @()
ForEach($DNSDomain in $nicdnsdomainsuffixsearchorder)
{
$tmp += "$($DNSDomain)`r"
}
$NicInformation += @{ Data = "DNS Search Suffixes"; Value = $tmp;
}
}
If($nic.dnsenabledforwinsresolution)
{
$tmp = "Yes"
}
Else
{
$tmp = "No"
}
$NicInformation += @{ Data = "DNS WINS Enabled"; Value = $tmp; }
If($nic.dnsserversearchorder -ne $Null -and
$nic.dnsserversearchorder.length -gt 0)
{
$nicdnsserversearchorder = $nic.dnsserversearchorder
$tmp = @()
ForEach($DNSServer in $nicdnsserversearchorder)
{
$tmp += "$($DNSServer)`r"
}
$NicInformation += @{ Data = "DNS Servers"; Value = $tmp; }
}
Switch ($nic.TcpipNetbiosOptions)
{
0 {$tmp = "Use NetBIOS setting from DHCP Server"}
1 {$tmp = "Enable NetBIOS"}
2 {$tmp = "Disable NetBIOS"}
Default {$tmp = "Unknown"}
}
$NicInformation += @{ Data = "NetBIOS Setting"; Value = $tmp; }
If($nic.winsenablelmhostslookup)
{
$tmp = "Yes"
}
Else
{
$tmp = "No"
}
$NicInformation += @{ Data = "WINS: Enabled LMHosts"; Value = $tmp; }
If(![String]::IsNullOrEmpty($nic.winshostlookupfile))
{
$NicInformation += @{ Data = "Host Lookup File"; Value =
$Nic.winshostlookupfile; }
}
If(![String]::IsNullOrEmpty($nic.winsprimaryserver))
{
$NicInformation += @{ Data = "Primary Server"; Value =
$Nic.winsprimaryserver; }
}
If(![String]::IsNullOrEmpty($nic.winssecondaryserver))
{
$NicInformation += @{ Data = "Secondary Server"; Value =
$Nic.winssecondaryserver; }
}
If(![String]::IsNullOrEmpty($nic.winsscopeid))
{
$NicInformation += @{ Data = "Scope ID"; Value =
$Nic.winsscopeid; }
}
$Table = AddWordTable -Hashtable $NicInformation -Columns Data,Value
-List -AutoFit $wdAutoFitFixed;
$Table.Rows.SetLeftIndent($Indent2TabStops,$wdAdjustNone)
FindWordDocumentEnd
$Table = $Null
}
}
Function SetWordHashTable
{
Param([string]$CultureCode)
#ca - Catalan
#da - Danish
#de - German
#en - English
#es - Spanish
#fi - Finnish
#fr - French
#nb - Norwegian
#nl - Dutch
#pt - Portuguese
#sv - Swedish
[string]$toc = $(
Switch ($CultureCode)
{
'ca-' { 'Taula automática 2'; Break }
'da-' { 'Automatisk tabel 2'; Break }
'de-' { 'Automatische Tabelle 2'; Break }
'en-' { 'Automatic Table 2'; Break }
'es-' { 'Tabla automática 2'; Break }
'fi-' { 'Automaattinen taulukko 2'; Break }
'fr-' { 'Table automatique 2'; Break } #changed 13-feb-2017 david
roquier and samuel legrand
'nb-' { 'Automatisk tabell 2'; Break }
'nl-' { 'Automatische inhoudsopgave 2'; Break }
'pt-' { 'Sumário Automático 2'; Break }
'sv-' { 'Automatisk innehållsförteckning2'; Break }
'zh-' { '自动目录 2'; Break }
}
)
$Script:myHash = @{}
$Script:myHash.Word_TableOfContents = $toc
$Script:myHash.Word_NoSpacing = $wdStyleNoSpacing
$Script:myHash.Word_Heading1 = $wdStyleheading1
$Script:myHash.Word_Heading2 = $wdStyleheading2
$Script:myHash.Word_Heading3 = $wdStyleheading3
$Script:myHash.Word_Heading4 = $wdStyleheading4
$Script:myHash.Word_TableGrid = $wdTableGrid
}
Function GetCulture
{
Param([int]$WordValue)
#ca - Catalan
#da - Danish
#de - German
#en - English
#es - Spanish
#fi - Finnish
#fr - French
#nb - Norwegian
#nl - Dutch
#pt - Portuguese
#sv - Swedish
Switch ($WordValue)
{
{$CatalanArray -contains $_} {$CultureCode = "ca-"}
{$DanishArray -contains $_} {$CultureCode = "da-"}
{$DutchArray -contains $_} {$CultureCode = "nl-"}
{$EnglishArray -contains $_} {$CultureCode = "en-"}
{$FinnishArray -contains $_} {$CultureCode = "fi-"}
{$FrenchArray -contains $_} {$CultureCode = "fr-"}
{$GermanArray -contains $_} {$CultureCode = "de-"}
{$NorwegianArray -contains $_} {$CultureCode = "nb-"}
{$PortugueseArray -contains $_} {$CultureCode = "pt-"}
{$SpanishArray -contains $_} {$CultureCode = "es-"}
{$SwedishArray -contains $_} {$CultureCode = "sv-"}
Default {$CultureCode = "en-"}
}
Return $CultureCode
}
Function ValidateCoverPage
{
Param([int]$xWordVersion, [string]$xCP, [string]$CultureCode)
$xArray = ""
Switch ($CultureCode)
{
'ca-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "En bandes", "Faceta",
"Filigrana",
"Integral", "Ió (clar)", "Ió (fosc)", "Línia
lateral",
"Moviment", "Quadrícula", "Retrospectiu", "Sector
(clar)",
"Sector (fosc)", "Semàfor", "Visualització", "Whisp")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alfabet", "Anual", "Austin",
"Conservador",
"Contrast", "Cubicles", "Diplomàtic", "Exposició",
"Línia lateral", "Mod", "Mosiac", "Moviment", "Paper
de diari",
"Perspectiva", "Piles", "Quadrícula", "Sobri",
"Transcendir", "Trencaclosques")
}
}
'da-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("BevægElse", "Brusen", "Ion (lys)",
"Filigran",
"Retro", "Semafor", "Visningsmaster", "Integral",
"Facet", "Gitter", "Stribet", "Sidelinje", "Udsnit
(lys)",
"Udsnit (mørk)", "Ion (mørk)", "Austin")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("BevægElse", "Moderat", "Perspektiv",
"Firkanter",
"Overskrid", "Alfabet", "Kontrast", "Stakke",
"Fliser", "Gåde",
"Gitter", "Austin", "Eksponering", "Sidelinje",
"Enkel",
"Nålestribet", "Årlig", "Avispapir", "Tradionel")
}
}
'de-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Semaphor", "Segment (hell)", "Ion
(hell)",
"Raster", "Ion (dunkel)", "Filigran", "Rückblick",
"Pfiff",
"ViewMaster", "Segment (dunkel)", "Verbunden",
"Bewegung",
"Randlinie", "Austin", "Integral", "Facette")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alphabet", "Austin", "Bewegung",
"Durchscheinend",
"Herausgestellt", "Jährlich", "Kacheln", "Kontrast",
"Kubistisch",
"Modern", "Nadelstreifen", "Perspektive", "Puzzle",
"Randlinie",
"Raster", "Schlicht", "Stapel", "Traditionell",
"Zeitungspapier")
}
}
'en-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "Banded", "Facet", "Filigree",
"Grid",
"Integral", "Ion (Dark)", "Ion (Light)", "Motion",
"Retrospect",
"Semaphore", "Sideline", "Slice (Dark)", "Slice
(Light)", "ViewMaster",
"Whisp")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alphabet", "Annual", "Austere", "Austin",
"Conservative",
"Contrast", "Cubicles", "Exposure", "Grid", "Mod",
"Motion", "Newsprint",
"Perspective", "Pinstripes", "Puzzle", "Sideline",
"Stacks", "Tiles", "Transcend")
}
}
'es-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Whisp", "Vista principal", "Filigrana",
"Austin",
"Slice (luz)", "Faceta", "Semáforo", "Retrospectiva",
"Cuadrícula",
"Movimiento", "Cortar (oscuro)", "Línea lateral",
"Ion (oscuro)",
"Ion (claro)", "Integral", "Con bandas")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alfabeto", "Anual", "Austero", "Austin",
"Conservador",
"Contraste", "Cuadrícula", "Cubículos", "Exposición",
"Línea lateral",
"Moderno", "Mosaicos", "Movimiento", "Papel
periódico",
"Perspectiva", "Pilas", "Puzzle", "Rayas",
"Sobrepasar")
}
}
'fi-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Filigraani", "Integraali", "Ioni
(tumma)",
"Ioni (vaalea)", "Opastin", "Pinta", "Retro",
"Sektori (tumma)",
"Sektori (vaalea)", "Vaihtuvavärinen", "ViewMaster",
"Austin",
"Kiehkura", "Liike", "Ruudukko", "Sivussa")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Aakkoset", "Askeettinen", "Austin",
"Kontrasti",
"Laatikot", "Liike", "Liituraita", "Mod", "Osittain
peitossa",
"Palapeli", "Perinteinen", "Perspektiivi", "Pinot",
"Ruudukko",
"Ruudut", "Sanomalehtipaperi", "Sivussa",
"Vuotuinen", "Ylitys")
}
}
'fr-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("ViewMaster", "Secteur (foncé)",
"Sémaphore",
"Rétrospective", "Ion (foncé)", "Ion (clair)",
"Intégrale",
"Filigrane", "Facette", "Secteur (clair)", "À
bandes", "Austin",
"Guide", "Whisp", "Lignes latérales", "Quadrillage")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Mosaïques", "Ligne latérale", "Annuel",
"Perspective",
"Contraste", "Emplacements de bureau", "Moderne",
"Blocs empilés",
"Rayures fines", "Austère", "Transcendant",
"Classique", "Quadrillage",
"Exposition", "Alphabet", "Mots croisés", "Papier
journal", "Austin", "Guide")
}
}
'nb-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "BevegElse", "Dempet", "Fasett",
"Filigran",
"Integral", "Ion (lys)", "Ion (mørk)", "Retrospekt",
"Rutenett",
"Sektor (lys)", "Sektor (mørk)", "Semafor",
"Sidelinje", "Stripet",
"ViewMaster")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alfabet", "Årlig", "Avistrykk", "Austin",
"Avlukker",
"BevegElse", "Engasjement", "Enkel", "Fliser",
"Konservativ",
"Kontrast", "Mod", "Perspektiv", "Puslespill",
"Rutenett", "Sidelinje",
"Smale striper", "Stabler", "Transcenderende")
}
}
'nl-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "Beweging", "Facet",
"Filigraan", "Gestreept",
"Integraal", "Ion (donker)", "Ion (licht)", "Raster",
"Segment (Light)", "Semafoor", "Slice (donker)",
"Spriet",
"Terugblik", "Terzijde", "ViewMaster")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Aantrekkelijk", "Alfabet", "Austin",
"Bescheiden",
"Beweging", "Blikvanger", "Contrast", "Eenvoudig",
"Jaarlijks",
"Krantenpapier", "Krijtstreep", "Kubussen", "Mod",
"Perspectief",
"Puzzel", "Raster", "Stapels",
"Tegels", "Terzijde")
}
}
'pt-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Animação", "Austin", "Em Tiras",
"Exibição Mestra",
"Faceta", "Fatia (Clara)", "Fatia (Escura)",
"Filete", "Filigrana",
"Grade", "Integral", "Íon (Claro)", "Íon (Escuro)",
"Linha Lateral",
"Retrospectiva", "Semáforo")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alfabeto", "Animação", "Anual",
"Austero", "Austin", "Baias",
"Conservador", "Contraste", "Exposição", "Grade",
"Ladrilhos",
"Linha Lateral", "Listras", "Mod", "Papel Jornal",
"Perspectiva", "Pilhas",
"Quebra-cabeça", "Transcend")
}
}
'sv-' {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "Band", "Fasett", "Filigran",
"Integrerad", "Jon (ljust)",
"Jon (mörkt)", "Knippe", "Rutnät", "RörElse", "Sektor
(ljus)", "Sektor (mörk)",
"Semafor", "Sidlinje", "VisaHuvudsida", "Återblick")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alfabetmönster", "Austin", "Enkelt",
"Exponering", "Konservativt",
"Kontrast", "Kritstreck", "Kuber", "Perspektiv",
"Plattor", "Pussel", "Rutnät",
"RörElse", "Sidlinje", "Sobert", "Staplat",
"Tidningspapper", "Årligt",
"Övergående")
}
}
Default {
If($xWordVersion -eq $wdWord2013)
{
$xArray = ("Austin", "Banded", "Facet",
"Filigree", "Grid", "Integral",
"Ion (Dark)", "Ion (Light)", "Motion",
"Retrospect", "Semaphore",
"Sideline", "Slice (Dark)", "Slice (Light)",
"ViewMaster", "Whisp")
}
ElseIf($xWordVersion -eq $wdWord2010)
{
$xArray = ("Alphabet", "Annual", "Austere",
"Austin", "Conservative",
"Contrast", "Cubicles", "Exposure", "Grid",
"Mod", "Motion", "Newsprint",
"Perspective", "Pinstripes", "Puzzle",
"Sideline", "Stacks", "Tiles", "Transcend")
}
}
}
Function SWExclusions
{
# original work by Shaun Ritchie
# performance improvements by Jeff Wouters, PowerShell MVP
# modified by Webster
# modified 3-jan-2014 to add displayversion
# bug found 30-jul-2014 by Sam Jacobs
# this function did not work if the SoftwareExlusions.txt file contained only
one line
$var = ""
$Tmp = '$InstalledApps | Where {'
$Exclusions = Get-Content "$($pwd.path)\SoftwareExclusions.txt" -EA 0
If($? -and $Exclusions -ne $Null)
{
If($Exclusions -is [array])
{
ForEach($Exclusion in $Exclusions)
{
$Tmp += "(`$`_.DisplayName -notlike ""$($Exclusion)"") -and
"
}
$var += $Tmp.Substring(0,($Tmp.Length - 6))
}
Else
{
# added 30-jul-2014 to handle if the file contained only one line
$tmp += "(`$`_.DisplayName -notlike ""$($Exclusions)"")"
$var = $tmp
}
$var += "} | Select-Object DisplayName, DisplayVersion | Sort
DisplayName -unique"
}
return $var
}
Function CheckWordPrereq
{
If((Test-Path REGISTRY::HKEY_CLASSES_ROOT\Word.Application) -eq $False)
{
$ErrorActionPreference = $SaveEAPreference
Write-Host "`n`n`t`tThis script directly outputs to Microsoft Word,
please install Microsoft Word`n`n"
Exit
}
Function ValidateCompanyName
{
$xResult = Test-RegistryValue
"HKCU:\Software\Microsoft\Office\Common\UserInfo" "CompanyName"
If($xResult)
{
Return Get-RegistryValue
"HKCU:\Software\Microsoft\Office\Common\UserInfo" "CompanyName"
}
Else
{
$xResult = Test-RegistryValue
"HKCU:\Software\Microsoft\Office\Common\UserInfo" "Company"
If($xResult)
{
Return Get-RegistryValue
"HKCU:\Software\Microsoft\Office\Common\UserInfo" "Company"
}
Else
{
Return ""
}
}
}
#http://stackoverflow.com/questions/5648931/test-if-registry-value-exists
# This Function just gets $True or $False
Function Test-RegistryValue($path, $name)
{
$key = Get-Item -LiteralPath $path -EA 0
$key -and $Null -ne $key.GetValue($name, $Null)
}
Function Check-NeededPSSnapins
{
Param([parameter(Mandatory = $True)][alias("Snapin")][string[]]$Snapins)
#Function specifics
$MissingSnapins = @()
[bool]$FoundMissingSnapin = $False
$LoadedSnapins = @()
$RegisteredSnapins = @()
ForEach($Snapin in $Snapins)
{
#check if the snapin is loaded
If(!($LoadedSnapins -like $snapin))
{
#Check if the snapin is missing
If(!($RegisteredSnapins -like $Snapin))
{
#set the flag if it's not already
If(!($FoundMissingSnapin))
{
$FoundMissingSnapin = $True
}
#add the entry to the list
$MissingSnapins += $Snapin
}
Else
{
#Snapin is registered, but not loaded, loading it now:
Write-Host "Loading Windows PowerShell snap-in: $snapin"
Add-PSSnapin -Name $snapin -EA 0
}
}
}
If($FoundMissingSnapin)
{
Write-Warning "Missing Windows PowerShell snap-ins Detected:"
$missingSnapins | % {Write-Warning "($_)"}
return $False
}
Else
{
Return $True
}
}
Function WriteWordLine
#Function created by Ryan Revord
#@rsrevord on Twitter
#Function created to make output to Word easy in this script
#updated 27-Mar-2014 to include font name, font size, italics and bold options
{
Param([int]$style=0,
[int]$tabs = 0,
[string]$name = '',
[string]$value = '',
[string]$fontName=$Null,
[int]$fontSize=0,
[bool]$italics=$False,
[bool]$boldface=$False,
[Switch]$nonewline)
#build # of tabs
While($tabs -gt 0)
{
$output += "`t"; $tabs--;
}
If(![String]::IsNullOrEmpty($fontName))
{
$Selection.Font.name = $fontName
}
If($fontSize -ne 0)
{
$Selection.Font.size = $fontSize
}
Function FindWordDocumentEnd
{
#return focus to main document
$Script:Doc.ActiveWindow.ActivePane.view.SeekView = $wdSeekMainDocument
#move to the end of the current document
$Script:Selection.EndKey($wdStory,$wdMove) | Out-Null
}
Function Process2008Policies
{
#Bandwidth
$xArray = ($Setting.TurnWallpaperOffState,
$Setting.TurnWindowContentsOffState, $Setting.TurnWindowContentsOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tBandwidth\Visual Effects\"
WriteWordLine 0 2 "Bandwidth\Visual Effects\"
If($Setting.TurnWallpaperOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn Off Desktop Wallpaper: "
$Setting.TurnWallpaperOffState
}
If($Setting.TurnMenuAnimationsOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn Off Menu and Windows Animations: "
$Setting.TurnMenuAnimationsOffState
}
If($Setting.TurnWindowContentsOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn Off Window Contents While Dragging: "
$Setting.TurnWindowContentsOffState
}
}
Switch ($Setting.ImageAccelerationCompressionLevel)
{
"HighCompression" {WriteWordLine 0 0 "High compression;
lower image quality"}
"MediumCompression" {WriteWordLine 0 0 "Medium compression;
good image quality"}
"LowCompression" {WriteWordLine 0 0 "Low compression;
best image quality"}
"NoCompression" {WriteWordLine 0 0 "Do not use lossy
compression"}
Default {WriteWordLine 0 0 "Compression level could not be
determined: $($Setting.ImageAccelerationCompressionLevel)"}
}
If($Setting.ImageAccelerationCompressionIsRestricted)
{
WriteWordLine 0 3 "Restrict compression to connections
under this "
WriteWordLine 0 4 "bandwidth\Threshold (Kb/sec): "
$Setting.ImageAccelerationCompressionLimit
}
WriteWordLine 0 3 "SpeedScreen Progressive Display compression
level: "
Switch ($Setting.ImageAccelerationProgressiveLevel)
{
"UltrahighCompression" {WriteWordLine 0 4 "Ultra high
compression; ultra low quality"}
"VeryHighCompression" {WriteWordLine 0 4 "Very high
compression; very low quality"}
"HighCompression" {WriteWordLine 0 4 "High
compression; low quality"}
"MediumCompression" {WriteWordLine 0 4 "Medium
compression; medium quality"}
"LowCompression" {WriteWordLine 0 4 "Low compression;
high quality"}
"Disabled" {WriteWordLine 0 4 "Disabled; no
progressive display"}
Default {WriteWordLine 0 0 "SpeedScreen Progressive Display
compression level could not be determined: $
($Setting.ImageAccelerationProgressiveLevel)"}
}
If($Setting.ImageAccelerationProgressiveIsRestricted)
{
WriteWordLine 0 3 "Restrict compression to connections
under this "
WriteWordLine 0 4 "bandwidth\Threshold (Kb/sec): "
$Setting.ImageAccelerationProgressiveLimit
}
WriteWordLine 0 3 "Use Heavyweight compression (extra CPU,
retains quality): " -nonewline
If($Setting.ImageAccelerationIsHeavyweightUsed)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
}
$xArray = ( $Setting.SessionAudioPercentState,
$Setting.SessionClipboardPercentState,
$Setting.SessionComportsPercentState,
$Setting.SessionDrivesPercentState,
$Setting.SessionLptPortsPercentState,
$Setting.SessionOemChannelsPercentState,
$Setting.SessionOverallState,
$Setting.SessionPrinterPercentState,
$Setting.SessionTwainRedirectionPercentState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tBandwidth\Session Limits (%)\"
WriteWordLine 0 2 'Bandwidth\Session Limits (%)\'
If($Setting.SessionAudioPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 'Audio: ' $Setting.SessionAudioPercentState
If($Setting.SessionAudioPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionAudioPercentLimit
}
}
If($Setting.SessionClipboardPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "Clipboard: "
$Setting.SessionClipboardPercentState
If($Setting.SessionClipboardPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionClipboardPercentLimit
}
}
If($Setting.SessionComportsPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "COM Ports: "
$Setting.SessionComportsPercentState
If($Setting.SessionComportsPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionComportsPercentLimit
}
}
If($Setting.SessionDrivesPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "Drives: " $Setting.SessionDrivesPercentState
If($Setting.SessionDrivesPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionDrivesPercentLimit
}
}
If($Setting.SessionLptPortsPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "LPT Ports: "
$Setting.SessionLptPortsPercentState
If($Setting.SessionLptPortsPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionLptPortsPercentLimit
}
}
If($Setting.SessionOemChannelsPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "OEM Virtual Channels: "
$Setting.SessionOemChannelsPercentState
If($Setting.SessionOemChannelsPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionOemChannelsPercentLimit
}
}
If($Setting.SessionPrinterPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "Printer: " $Setting.SessionPrinterPercentState
If($Setting.SessionPrinterPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionPrinterPercentLimit
}
}
If($Setting.SessionTwainRedirectionPercentState -ne "NotConfigured")
{
WriteWordLine 0 3 "TWAIN Redirection: "
$Setting.SessionTwainRedirectionPercentState
If($Setting.SessionTwainRedirectionPercentState -eq "Enabled")
{
WriteWordLine 0 4 'Limit (%): '
$Setting.SessionTwainRedirectionPercentLimit
}
}
}
$xArray = ( $Setting.ClientMicrophonesState,
$Setting.ClientSoundQualityState,
$Setting.TurnClientAudioMappingOffState,
$Setting.ClientDrivesState,
$Setting.ClientDriveMappingState,
$Setting.ClientAsynchronousWritesState,
$Setting.TwainRedirectionState,
$Setting.TurnClipboardMappingOffState,
$Setting.TurnOemVirtualChannelsOffState,
$Setting.TurnComPortsOffState,
$Setting.TurnLptPortsOffState,
$Setting.TurnVirtualComPortMappingOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tClient Devices\Resources"
WriteWordLine 0 2 "Client Devices\Resources"
If($Setting.ClientMicrophonesState -ne "NotConfigured")
{
WriteWordLine 0 3 "Audio\Microphones: "
$Setting.ClientMicrophonesState
If($Setting.ClientMicrophonesState -eq "Enabled")
{
If($Setting.ClientMicrophonesAreUsed)
{
WriteWordLine 0 4 "Use client microphones for audio
input"
}
Else
{
WriteWordLine 0 4 "Do not use client microphones for
audio input"
}
}
}
If($Setting.ClientSoundQualityState -ne "NotConfigured")
{
WriteWordLine 0 3 "Audio\Sound quality: "
$Setting.ClientSoundQualityState
If($Setting.ClientSoundQualityState)
{
WriteWordLine 0 4 "Maximum allowable client audio quality:
"
Switch ($Setting.ClientSoundQualityLevel)
{
"Medium" {WriteWordLine 0 5 "Optimized for Speech"}
"Low" {WriteWordLine 0 5 "Low Bandwidth"}
"High" {WriteWordLine 0 5 "High Definition"}
Default {WriteWordLine 0 0 "Maximum allowable client
audio quality could not be determined: $($Setting.ClientSoundQualityLevel)"}
}
}
}
If($Setting.TurnClientAudioMappingOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Audio\Turn off speakers: "
$Setting.TurnClientAudioMappingOffState
If($Setting.TurnClientAudioMappingOffState -eq "Enabled")
{
WriteWordLine 0 4 "Turn off audio mapping to client
speakers"
}
}
$xArray = ($Setting.TwainRedirectionState,
$Setting.TurnClipboardMappingOffState, $Setting.TurnOemVirtualChannelsOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tClient Devices\Resources\Other"
WriteWordLine 0 2 "Client Devices\Resources\Other"
If($Setting.TwainRedirectionState -ne "NotConfigured")
{
WriteWordLine 0 3 "Configure TWAIN redirection: "
$Setting.TwainRedirectionState
If($Setting.TwainRedirectionState -eq "Enabled")
{
If($Setting.TwainRedirectionAllowed)
{
WriteWordLine 0 4 "Allow TWAIN redirection"
If($Setting.TwainRedirectionImageCompression
-eq "NoCompression")
{
WriteWordLine 0 4 "Do not use lossy
compression for high color images"
}
Else
{
WriteWordLine 0 4 "Use lossy compression
for high color images: "
Switch
($Setting.TwainRedirectionImageCompression)
{
"HighCompression" {WriteWordLine
0 5 "High compression; lower image quality"}
"MediumCompression" {WriteWordLine
0 5 "Medium compression; good image quality"}
"LowCompression" {WriteWordLine
0 5 "Low compression; best image quality"}
Default {WriteWordLine 0 0 "Lossy
compression for high color images could not be determined: $
($Setting.TwainRedirectionImageCompression)"}
}
}
}
Else
{
WriteWordLine 0 4 "Do not allow TWAIN
redirection"
}
}
}
If($Setting.TurnClipboardMappingOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn off clipboard mapping: "
$Setting.TurnClipboardMappingOffState
}
If($Setting.TurnOemVirtualChannelsOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn off OEM virtual channels: "
$Setting.TurnOemVirtualChannelsOffState
}
}
$xArray = ($Setting.TurnComPortsOffState,
$Setting.TurnLptPortsOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tClient Devices\Resources\Ports"
WriteWordLine 0 2 "Client Devices\Resources\Ports"
If($Setting.TurnComPortsOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn off COM ports: "
$Setting.TurnComPortsOffState
}
If($Setting.TurnLptPortsOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn off LPT ports: "
$Setting.TurnLptPortsOffState
}
}
Switch ($Setting.PrinterPropertiesRetentionOption)
{
"FallbackToProfile" {WriteWordLine 0 0 "Held in
profile only if not saved on client"}
"RetainedInUserProfile" {WriteWordLine 0 0 "Retained
in user profile only"}
"SavedOnClientDevice" {WriteWordLine 0 0 "Saved on
the client device only"}
Default {WriteWordLine 0 0 "Printer properties
retention could not be determined: $($Setting.PrinterPropertiesRetentionOption)"}
}
}
}
If($Setting.PrinterJobRoutingState -ne "NotConfigured")
{
WriteWordLine 0 3 "Print job routing: "
$Setting.PrinterJobRoutingState
If($Setting.PrinterJobRoutingState -eq "Enabled")
{
WriteWordLine 0 4 "For client printers on a network printer
server: "
If($Setting.PrinterJobRoutingDirect)
{
WriteWordLine 0 5 "Connect directly to network print
server if possible"
}
Else
{
WriteWordLine 0 5 "Always connect indirectly as a
client printer"
}
}
}
If($Setting.TurnClientPrinterMappingOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Turn off client printer mapping: "
$Setting.TurnClientPrinterMappingOffState
}
}
Switch ($Setting.UniversalDriverOption)
{
"FallbackOnly" {WriteWordLine 0 4 "Use universal
driver only if requested driver is unavailable"}
"SpecificOnly" {WriteWordLine 0 4 "Use only printer
model specific drivers"}
"ExclusiveOnly" {WriteWordLine 0 4 "Use universal
driver only"}
Default {WriteWordLine 0 0 "When auto-creating client
printers could not be determined: $($Setting.UniversalDriverOption)"}
}
}
}
}
If($SessionPrinterSettings.Collated)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
WriteWordLine 0 5 "Print Quality`t: "
-nonewline
Switch
($SessionPrinterSettings.PrintQuality)
{
"Dpi600" {WriteWordLine 0 0 "600
dpi"}
"Dpi300" {WriteWordLine 0 0 "300
dpi"}
"Dpi150" {WriteWordLine 0 0 "150
dpi"}
"Dpi75" {WriteWordLine 0 0 "75
dpi"}
Default {WriteWordLine 0 0 "Print
Quality could not be determined: $($SessionPrinterSettings.PrintQuality)"}
}
WriteWordLine 0 5 "Orientation`t: "
$SessionPrinterSettings.PaperOrientation
WriteWordLine 0 5 "Apply customized
settings at every logon: " -nonewline
If($SessionPrinterSettings.ApplySettingsOnLogOn)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
}
}
}
WriteWordLine 0 3 "Client's Default printer: "
If($Setting.SessionPrinterDefaultOption -eq "SetToPrinterIndex")
{
WriteWordLine 0 4
$Setting.SessionPrinterList[$Setting.SessionPrinterDefaultIndex]
}
Else
{
Switch ($Setting.SessionPrinterDefaultOption)
{
"SetToClientMainPrinter" {WriteWordLine 0 4 "Set
Default printer to the client's main printer"}
"DoNotAdjust" {WriteWordLine 0 4 "Do not
adjust the user's Default printer"}
Default {WriteWordLine 0 0 "Client's Default printer
could not be determined: $($Setting.SessionPrinterDefaultOption)"}
}
}
}
}
#User Workspace
$xArray = ($Setting.ConcurrentSessionsState,
$Setting.ZonePreferenceAndFailoverState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tUser Workspace\Connections"
WriteWordLine 0 2 "User Workspace\Connections"
If($Setting.ConcurrentSessionsState -ne "NotConfigured")
{
WriteWordLine 0 3 "Limit total concurrent sessions: "
$Setting.ConcurrentSessionsState
If($Setting.ConcurrentSessionsState -eq "Enabled")
{
WriteWordLine 0 4 "Limit: "
$Setting.ConcurrentSessionsLimit
}
}
If($Setting.ZonePreferenceAndFailoverState -ne "NotConfigured")
{
WriteWordLine 0 3 "Zone preference and failover: "
$Setting.ZonePreferenceAndFailoverState
If($Setting.ZonePreferenceAndFailoverState -eq "Enabled")
{
WriteWordLine 0 4 "Zone preference settings:"
ForEach($Pref in $Setting.ZonePreferences)
{
WriteWordLine 0 5 $Pref
}
}
}
}
$xArray = ($Setting.TurnClientLocalTimeEstimationOffState,
$Setting.TurnClientLocalTimeEstimationOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tUser Workspace\Time Zones"
WriteWordLine 0 2 "User Workspace\Time Zones"
If($Setting.TurnClientLocalTimeEstimationOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Do not estimate local time for legacy clients:
" $Setting.TurnClientLocalTimeEstimationOffState
}
If($Setting.TurnClientLocalTimeEstimationOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Do not use Client's local time: "
$Setting.TurnClientLocalTimeOffState
}
}
$xArray = ($Setting.CentralCredentialStoreState,
$Setting.TurnPasswordManagerOffState)
If($xArray -contains "Enabled" -or $xArray -contains "Disabled")
{
Write-Verbose "$(Get-Date): `t`t`tUser Workspace\Citrix Password
Manager"
WriteWordLine 0 2 "User Workspace\Citrix Password Manager"
If($Setting.CentralCredentialStoreState -ne "NotConfigured")
{
WriteWordLine 0 3 "Central Credential Store: "
$Setting.CentralCredentialStoreState
If($Setting.CentralCredentialStoreState -eq "Enabled")
{
If($Setting.CentralCredentialStorePath)
{
WriteWordLine 0 4 "UNC path of Central Credential
Store: " $Setting.CentralCredentialStorePath
}
Else
{
WriteWordLine 0 4 "No UNC path to Central Credential
Store entered"
}
}
}
If($Setting.TurnPasswordManagerOffState -ne "NotConfigured")
{
WriteWordLine 0 3 "Do not use Citrix Password Manager: "
$Setting.TurnPasswordManagerOffState
}
}
#Security
If($Setting.SecureIcaEncriptionState -ne "NotConfigured")
{
Write-Verbose "$(Get-Date): `t`t`tSecurity\Encryption\SecureICA
encryption"
WriteWordLine 0 2 "Security\Encryption\SecureICA encryption: "
$Setting.SecureIcaEncriptionState
If($Setting.SecureIcaEncriptionState -eq "Enabled")
{
WriteWordLine 0 3 "Encryption level: " -nonewline
Switch ($Setting.SecureIcaEncriptionLevel)
{
"Unknown" {WriteWordLine 0 0 "Unknown encryption"}
"Basic" {WriteWordLine 0 0 "Basic"}
"LogOn" {WriteWordLine 0 0 "RC5 (128 bit) logon only"}
"Bits40" {WriteWordLine 0 0 "RC5 (40 bit)"}
"Bits56" {WriteWordLine 0 0 "RC5 (56 bit)"}
"Bits128" {WriteWordLine 0 0 "RC5 (128 bit)"}
Default {WriteWordLine 0 0 "SecureICA minimum encryption
level could not be determined: $($Setting.MinimumEncryptionLevel.Value)"}
}
}
}
Function AbortScript
{
$Script:Word.quit()
Write-Verbose "$(Get-Date): System Cleanup"
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Script:Word) |
Out-Null
If(Test-Path variable:global:word)
{
Remove-Variable -Name word -Scope Global
}
[gc]::collect()
[gc]::WaitForPendingFinalizers()
Write-Verbose "$(Get-Date): Script has been aborted"
$ErrorActionPreference = $SaveEAPreference
Exit
}
Function FindWordDocumentEnd
{
#return focus to main document
$Script:Doc.ActiveWindow.ActivePane.view.SeekView = $wdSeekMainDocument
#move to the end of the current document
$Script:Selection.EndKey($wdStory,$wdMove) | Out-Null
}
Function BuildTableForServer
{
Param([Array]$xArray)
FindWordDocumentEnd
$xArray = $Null
}
<#
.Synopsis
Add a table to a Microsoft Word document
.DESCRIPTION
This function adds a table to a Microsoft Word document from either an array
of
Hashtables or an array of PSCustomObjects.
Using this function is quicker than setting each table cell individually but
can
only utilise the built-in MS Word table autoformats. Individual tables cells
can
be altered after the table has been appended to the document (a table
reference
is returned).
.EXAMPLE
AddWordTable -Hashtable $HashtableArray
This example adds table to the MS Word document, utilising all key/value
pairs in
the array of hashtables. Column headers will display the key names as
defined.
Note: the columns might not be displayed in the order that they were defined.
To
ensure columns are displayed in the required order utilise the -Columns
parameter.
.EXAMPLE
AddWordTable -Hashtable $HashtableArray -List
This example adds table to the MS Word document, utilising all key/value
pairs in
the array of hashtables. No column headers will be added, in a ListView
format.
Note: the columns might not be displayed in the order that they were defined.
To
ensure columns are displayed in the required order utilise the -Columns
parameter.
.EXAMPLE
AddWordTable -CustomObject $PSCustomObjectArray
This example adds table to the MS Word document, utilising all note property
names
the array of PSCustomObjects. Column headers will display the note property
names.
Note: the columns might not be displayed in the order that they were defined.
To
ensure columns are displayed in the required order utilise the -Columns
parameter.
.EXAMPLE
AddWordTable -Hashtable $HashtableArray -Columns
FirstName,LastName,EmailAddress
This example adds a table to the MS Word document, but only using the
specified
key names: FirstName, LastName and EmailAddress. If other keys are present in
the
array of Hashtables they will be ignored.
.EXAMPLE
AddWordTable -CustomObject $PSCustomObjectArray -Columns
FirstName,LastName,EmailAddress -Headers "First Name","Last Name","Email Address"
This example adds a table to the MS Word document, but only using the
specified
PSCustomObject note properties: FirstName, LastName and EmailAddress. If
other note
properties are present in the array of PSCustomObjects they will be ignored.
The
display names for each specified column header has been overridden to display
a
custom header. Note: the order of the header names must match the specified
columns.
#>
Function AddWordTable
{
[CmdletBinding()]
Param
(
# Array of Hashtable (including table headers)
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,
ParameterSetName='Hashtable', Position=0)]
[ValidateNotNullOrEmpty()] [System.Collections.Hashtable[]] $Hashtable,
# Array of PSCustomObjects
[Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true,
ParameterSetName='CustomObject', Position=0)]
[ValidateNotNullOrEmpty()] [PSCustomObject[]] $CustomObject,
# Array of Hashtable key names or PSCustomObject property names to
include, in display order.
# If not supplied then all Hashtable keys or all PSCustomObject
properties will be displayed.
[Parameter(ValueFromPipelineByPropertyName=$true)] [AllowNull()]
[string[]] $Columns = $null,
# Array of custom table header strings in display order.
[Parameter(ValueFromPipelineByPropertyName=$true)] [AllowNull()]
[string[]] $Headers = $null,
# AutoFit table behavior.
[Parameter(ValueFromPipelineByPropertyName=$true)] [AllowNull()] [int]
$AutoFit = -1,
# List view (no headers)
[Switch] $List,
# Grid lines
[Switch] $NoGridLines,
# Built-in Word table formatting style constant
# Would recommend only $wdTableFormatContempory for normal usage
(possibly $wdTableFormatList5 for List view)
[Parameter(ValueFromPipelineByPropertyName=$true)] [int] $Format = 0
)
Begin
{
Write-Debug ("Using parameter set '{0}'" -f
$PSCmdlet.ParameterSetName);
## Check if -Columns wasn't specified but -Headers were (saves some
additional parameter sets!)
If(($Columns -eq $null) -and ($Headers -ne $null))
{
Write-Warning "No columns specified and therefore, specified
headers will be ignored.";
$Columns = $null;
}
ElseIf(($Columns -ne $null) -and ($Headers -ne $null))
{
## Check if number of specified -Columns matches number of
specified -Headers
If($Columns.Length -ne $Headers.Length)
{
Write-Error "The specified number of columns does not match
the specified number of headers.";
}
} ## end elseif
} ## end Begin
Process
{
## Build the Word table data string to be converted to a range and then
a table later.
[System.Text.StringBuilder] $WordRangeString = New-Object
System.Text.StringBuilder;
Switch ($PSCmdlet.ParameterSetName)
{
'CustomObject'
{
If($Columns -eq $null)
{
## Build the available columns from all availble
PSCustomObject note properties
[string[]] $Columns = @();
## Add each NoteProperty name to the array
ForEach($Property in ($CustomObject | Get-Member
-MemberType NoteProperty))
{
$Columns += $Property.Name;
}
}
Default
{ ## Hashtable
If($Columns -eq $null)
{
## Build the available columns from all available
hashtable keys. Hopefully
## all Hashtables have the same keys (they should for
a table).
$Columns = $Hashtable[0].Keys;
}
#the next line causes the heading row to flow across page breaks
$WordTable.Rows.First.Headingformat = $wdHeadingFormatTrue;
If(!$NoGridLines)
{
$WordTable.Borders.InsideLineStyle = $wdLineStyleSingle;
$WordTable.Borders.OutsideLineStyle = $wdLineStyleSingle;
}
Return $WordTable;
} ## end Process
}
<#
.Synopsis
Sets the format of one or more Word table cells
.DESCRIPTION
This function sets the format of one or more table cells, either from a
collection
of Word COM object cell references, an individual Word COM object cell
reference or
a hashtable containing Row and Column information.
The font name, font size, bold, italic , underline and shading values can be
used.
.EXAMPLE
SetWordCellFormat -Hashtable $Coordinates -Table $TableReference -Bold
This example sets all text to bold that is contained within the
$TableReference
Word table, using an array of hashtables. Each hashtable contain a pair of
co-
ordinates that is used to select the required cells. Note: the hashtable must
contain the .Row and .Column key names. For example:
@ { Row = 7; Column = 3 } to set the cell at row 7 and column 3 to bold.
.EXAMPLE
$RowCollection = $Table.Rows.First.Cells
SetWordCellFormat -Collection $RowCollection -Bold -Size 10
This example sets all text to size 8 and bold for all cells that are
contained
within the first row of the table.
Note: the $Table.Rows.First.Cells returns a collection of Word COM cells
objects
that are in the first table row.
.EXAMPLE
$ColumnCollection = $Table.Columns.Item(2).Cells
SetWordCellFormat -Collection $ColumnCollection -BackgroundColor 255
This example sets the background (shading) of all cells in the table's second
column to red.
Note: the $Table.Columns.Item(2).Cells returns a collection of Word COM cells
objects
that are in the table's second column.
.EXAMPLE
SetWordCellFormat -Cell $Table.Cell(17,3) -Font "Tahoma" -Color 16711680
This example sets the font to Tahoma and the text color to blue for the cell
located
in the table's 17th row and 3rd column.
Note: the $Table.Cell(17,3) returns a single Word COM cells object.
#>
Function SetWordCellFormat
{
[CmdletBinding(DefaultParameterSetName='Collection')]
Param (
# Word COM object cell collection reference
[Parameter(Mandatory=$true, ValueFromPipeline=$true,
ParameterSetName='Collection', Position=0)] [ValidateNotNullOrEmpty()] $Collection,
# Word COM object individual cell reference
[Parameter(Mandatory=$true, ParameterSetName='Cell', Position=0)]
[ValidateNotNullOrEmpty()] $Cell,
# Hashtable of cell co-ordinates
[Parameter(Mandatory=$true, ParameterSetName='Hashtable', Position=0)]
[ValidateNotNullOrEmpty()] [System.Collections.Hashtable[]] $Coordinates,
# Word COM object table reference
[Parameter(Mandatory=$true, ParameterSetName='Hashtable', Position=1)]
[ValidateNotNullOrEmpty()] $Table,
# Font name
[Parameter()] [AllowNull()] [string] $Font = $null,
# Font color
[Parameter()] [AllowNull()] $Color = $null,
# Font size
[Parameter()] [ValidateNotNullOrEmpty()] [int] $Size = 0,
# Cell background color
[Parameter()] [AllowNull()] $BackgroundColor = $null,
# Force solid background color
[Switch] $Solid,
[Switch] $Bold,
[Switch] $Italic,
[Switch] $Underline
)
Begin
{
Write-Debug ("Using parameter set '{0}'." -f
$PSCmdlet.ParameterSetName);
}
Process
{
Switch ($PSCmdlet.ParameterSetName)
{
'Collection' {
ForEach($Cell in $Collection)
{
If($BackgroundColor -ne $null)
{ $Cell.Shading.BackgroundPatternColor = $BackgroundColor; }
If($Bold) { $Cell.Range.Font.Bold = $true; }
If($Italic) { $Cell.Range.Font.Italic = $true; }
If($Underline) { $Cell.Range.Font.Underline = 1; }
If($Font -ne $null) { $Cell.Range.Font.Name =
$Font; }
If($Color -ne $null) { $Cell.Range.Font.Color =
$Color; }
If($Size -ne 0) { $Cell.Range.Font.Size = $Size; }
If($Solid) { $Cell.Shading.Texture = 0; } ##
wdTextureNone
} # end foreach
} # end Collection
'Cell'
{
If($Bold) { $Cell.Range.Font.Bold = $true; }
If($Italic) { $Cell.Range.Font.Italic = $true; }
If($Underline) { $Cell.Range.Font.Underline = 1; }
If($Font -ne $null) { $Cell.Range.Font.Name = $Font; }
If($Color -ne $null) { $Cell.Range.Font.Color = $Color; }
If($Size -ne 0) { $Cell.Range.Font.Size = $Size; }
If($BackgroundColor -ne $null)
{ $Cell.Shading.BackgroundPatternColor = $BackgroundColor; }
If($Solid) { $Cell.Shading.Texture = 0; } ## wdTextureNone
} # end Cell
'Hashtable'
{
ForEach($Coordinate in $Coordinates)
{
$Cell = $Table.Cell($Coordinate.Row,
$Coordinate.Column);
If($Bold) { $Cell.Range.Font.Bold = $true; }
If($Italic) { $Cell.Range.Font.Italic = $true; }
If($Underline) { $Cell.Range.Font.Underline = 1; }
If($Font -ne $null) { $Cell.Range.Font.Name =
$Font; }
If($Color -ne $null) { $Cell.Range.Font.Color =
$Color; }
If($Size -ne 0) { $Cell.Range.Font.Size = $Size; }
If($BackgroundColor -ne $null)
{ $Cell.Shading.BackgroundPatternColor = $BackgroundColor; }
If($Solid) { $Cell.Shading.Texture = 0; } ##
wdTextureNone
}
} # end Hashtable
} # end switch
} # end process
}
<#
.Synopsis
Sets alternate row colors in a Word table
.DESCRIPTION
This function sets the format of alternate rows within a Word table using the
specified $BackgroundColor. This function is expensive (in performance terms)
as
it recursively sets the format on alternate rows. It would be better to pick
one
of the predefined table formats (if one exists)? Obviously the more rows, the
longer it takes :'(
This example sets every other table (starting with the second) row and sets
the
background color to light orange (weColorLightOrange).
#>
Function SetWordTableAlternateRowColor
{
[CmdletBinding()]
Param (
# Word COM object table reference
[Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)]
[ValidateNotNullOrEmpty()] $Table,
# Alternate row background color
[Parameter(Mandatory=$true, Position=1)] [ValidateNotNull()] [int]
$BackgroundColor,
# Alternate row starting seed
[Parameter(ValueFromPipelineByPropertyName=$true, Position=2)]
[ValidateSet('First','Second')] [string] $Seed = 'First'
)
Process
{
$StartDateTime = Get-Date;
Write-Debug ("{0}: `t`tSetting alternate table row colors.." -f
$StartDateTime);
## Determine the row seed (only really need to check for 'Second' and
default to 'First' otherwise
If($Seed.ToLower() -eq 'second')
{
$StartRowIndex = 2;
}
Else
{
$StartRowIndex = 1;
}
$Table.Rows.Item($AlternateRowIndex).Shading.BackgroundPatternColor =
$BackgroundColor;
}
## I've put verbose calls in here we can see how expensive this
functionality actually is.
$EndDateTime = Get-Date;
$ExecutionTime = New-TimeSpan -Start $StartDateTime -End $EndDateTime;
Write-Debug ("{0}: `t`tDone setting alternate row style color in '{1}'
seconds" -f $EndDateTime, $ExecutionTime.TotalSeconds);
}
}
Function ShowScriptOptions
{
Write-Verbose "$(Get-Date): "
Write-Verbose "$(Get-Date): "
Write-Verbose "$(Get-Date): Company Name : $($Script:CoName)"
Write-Verbose "$(Get-Date): Cover Page : $($CoverPage)"
Write-Verbose "$(Get-Date): User Name : $($UserName)"
Write-Verbose "$(Get-Date): Save As PDF : $($PDF)"
Write-Verbose "$(Get-Date): Save As WORD : $($MSWORD)"
Write-Verbose "$(Get-Date): Add DateTime : $($AddDateTime)"
Write-Verbose "$(Get-Date): HW Inventory : $($Hardware)"
Write-Verbose "$(Get-Date): SW Inventory : $Software"
If(!$Summary)
{
Write-Verbose "$(Get-Date): Start Date : $($StartDate)"
Write-Verbose "$(Get-Date): End Date : $($EndDate)"
}
Write-Verbose "$(Get-Date): Section : $($Section)"
Write-Verbose "$(Get-Date): Summary : $($Summary)"
Write-Verbose "$(Get-Date): Filename1 : $($Script:FileName1)"
If($PDF)
{
Write-Verbose "$(Get-Date): Filename2 : $($Script:FileName2)"
}
Write-Verbose "$(Get-Date): OS Detected : $($RunningOS)"
Write-Verbose "$(Get-Date): PSUICulture : $($PSUICulture)"
Write-Verbose "$(Get-Date): PSCulture : $($PSCulture)"
Write-Verbose "$(Get-Date): Word version : $($Script:WordProduct)"
Write-Verbose "$(Get-Date): Word language: $($Script:WordLanguageValue)"
Write-Verbose "$(Get-Date): PoSH version : $($Host.Version)"
Write-Verbose "$(Get-Date): "
Write-Verbose "$(Get-Date): Script start : $($Script:StartTime)"
Write-Verbose "$(Get-Date): "
Write-Verbose "$(Get-Date): "
}
Function SetupWord
{
Write-Verbose "$(Get-Date): Setting up Word"
# Setup word for output
Write-Verbose "$(Get-Date): Create Word comObject. Ignore the next message."
$Script:Word = New-Object -comobject "Word.Application" -EA 0
SetWordHashTable $Script:WordCultureCode
[int]$Script:WordVersion = [int]$Script:Word.Version
If($Script:WordVersion -eq $wdWord2013)
{
$Script:WordProduct = "Word 2013"
}
ElseIf($Script:WordVersion -eq $wdWord2010)
{
$Script:WordProduct = "Word 2010"
}
ElseIf($Script:WordVersion -eq $wdWord2007)
{
$ErrorActionPreference = $SaveEAPreference
Write-Error "`n`n`t`tMicrosoft Word 2007 is no longer
supported.`n`n`t`tScript will end.`n`n"
AbortScript
}
Else
{
$ErrorActionPreference = $SaveEAPreference
Write-Error "`n`n`t`tYou are running an untested or unsupported version
of Microsoft Word.`n`n`t`tScript will end.`n`n`t`tPlease send info on your version
of Word to webster@carlwebster.com`n`n"
AbortScript
}
If([String]::IsNullOrEmpty($TmpName))
{
Write-Warning "`n`n`t`tCompany Name is blank so Cover Page will
not show a Company Name."
Write-Warning "`n`t`tCheck
HKCU:\Software\Microsoft\Office\Common\UserInfo for Company or CompanyName value."
Write-Warning "`n`t`tYou may want to use the -CompanyName
parameter if you need a Company Name on the cover page.`n`n"
}
Else
{
$Script:CoName = $TmpName
Write-Verbose "$(Get-Date): Updated company name to $
($Script:CoName)"
}
}
'da-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Sidelinje"
$CPChanged = $True
}
}
'de-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Randlinie"
$CPChanged = $True
}
}
'es-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Línea lateral"
$CPChanged = $True
}
}
'fi-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Sivussa"
$CPChanged = $True
}
}
'fr-' {
If($CoverPage -eq "Sideline")
{
If($Script:WordVersion -eq $wdWord2013)
{
$CoverPage = "Lignes latérales"
$CPChanged = $True
}
Else
{
$CoverPage = "Ligne latérale"
$CPChanged = $True
}
}
}
'nb-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Sidelinje"
$CPChanged = $True
}
}
'nl-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Terzijde"
$CPChanged = $True
}
}
'pt-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Linha Lateral"
$CPChanged = $True
}
}
'sv-' {
If($CoverPage -eq "Sideline")
{
$CoverPage = "Sidlinje"
$CPChanged = $True
}
}
}
If($CPChanged)
{
Write-Verbose "$(Get-Date): Changed Default Cover Page from
Sideline to $($CoverPage)"
}
}
If(!$ValidCP)
{
$ErrorActionPreference = $SaveEAPreference
Write-Verbose "$(Get-Date): Word language value $
($Script:WordLanguageValue)"
Write-Verbose "$(Get-Date): Culture code $($Script:WordCultureCode)"
Write-Error "`n`n`t`tFor $($Script:WordProduct), $($CoverPage) is not a
valid Cover Page option.`n`n`t`tScript cannot continue.`n`n"
AbortScript
}
ShowScriptOptions
$Script:Word.Visible = $False
#http://jdhitsolutions.com/blog/2012/05/san-diego-2012-powershell-deep-dive-
slides-and-demos/
#using Jeff's Demo-WordReport.ps1 file for examples
Write-Verbose "$(Get-Date): Load Word Templates"
[bool]$Script:CoverPagesExist = $False
[bool]$BuildingBlocksExist = $False
$Script:Word.Templates.LoadBuildingBlocks()
#word 2010/2013
$BuildingBlocksCollection = $Script:Word.Templates | Where {$_.name -eq
"Built-In Building Blocks.dotx"}
$BuildingBlocksCollection |
ForEach{
If ($_.BuildingBlockEntries.Item($CoverPage).Name -eq $CoverPage)
{
$BuildingBlocks = $_
}
}
If($BuildingBlocks -ne $Null)
{
$BuildingBlocksExist = $True
Try
{
$part = $BuildingBlocks.BuildingBlockEntries.Item($CoverPage)
}
Catch
{
$part = $Null
}
If(!$Script:CoverPagesExist)
{
Write-Verbose "$(Get-Date): Cover Pages are not installed or the Cover
Page $($CoverPage) does not exist."
Write-Warning "Cover Pages are not installed or the Cover Page $
($CoverPage) does not exist."
Write-Warning "This report will not have a Cover Page."
}
$Script:Selection = $Script:Word.Selection
If($Script:Selection -eq $Null)
{
Write-Verbose "$(Get-Date): "
$ErrorActionPreference = $SaveEAPreference
Write-Error "`n`n`t`tAn unknown error happened selecting the entire
Word document for default formatting options.`n`n`t`tScript cannot continue.`n`n"
AbortScript
}
#set Default tab stops to 1/2 inch (this line is not from Jeff Hicks)
#36 = .50"
$Script:Word.ActiveDocument.DefaultTabStop = 36
#Disable Spell and Grammar Check to resolve issue and improve performance
(from Pat Coughlin)
Write-Verbose "$(Get-Date): Disable grammar and spell checking"
#bug reported 1-Apr-2014 by Tim Mangan
#save current options first before turning them off
$Script:CurrentGrammarOption = $Script:Word.Options.CheckGrammarAsYouType
$Script:CurrentSpellingOption = $Script:Word.Options.CheckSpellingAsYouType
$Script:Word.Options.CheckGrammarAsYouType = $False
$Script:Word.Options.CheckSpellingAsYouType = $False
If($BuildingBlocksExist)
{
#insert new page, getting ready for table of contents
Write-Verbose "$(Get-Date): Insert new page, getting ready for table of
contents"
$part.Insert($Script:Selection.Range,$True) | Out-Null
$Script:Selection.InsertNewPage()
#table of contents
Write-Verbose "$(Get-Date): Table of Contents - $
($myHash.Word_TableOfContents)"
$toc =
$BuildingBlocks.BuildingBlockEntries.Item($myHash.Word_TableOfContents)
If($toc -eq $Null)
{
Write-Verbose "$(Get-Date): "
Write-Verbose "$(Get-Date): Table of Content - $
($myHash.Word_TableOfContents) could not be retrieved."
Write-Warning "This report will not have a Table of Contents."
}
Else
{
$toc.insert($Script:Selection.Range,$True) | Out-Null
}
}
Else
{
Write-Verbose "$(Get-Date): Table of Contents are not installed."
Write-Warning "Table of Contents are not installed so this report will
not have a Table of Contents."
}
FindWordDocumentEnd
Write-Verbose "$(Get-Date):"
#end of Jeff Hicks
}
Function UpdateDocumentProperties
{
Param([string]$AbstractTitle, [string]$SubjectTitle)
#Update document properties
If($MSWORD -or $PDF)
{
If($Script:CoverPagesExist)
{
Write-Verbose "$(Get-Date): Set Cover Page Properties"
_SetDocumentProperty $Script:Doc.BuiltInDocumentProperties
"Company" $Script:CoName
_SetDocumentProperty $Script:Doc.BuiltInDocumentProperties
"Title" $Script:title
_SetDocumentProperty $Script:Doc.BuiltInDocumentProperties
"Author" $username
_SetDocumentProperty $Script:Doc.BuiltInDocumentProperties
"Subject" $SubjectTitle
$ab.Text = $abstract
Function SaveandCloseDocumentandShutdownWord
{
#bug fix 1-Apr-2014
#reset Grammar and Spelling options back to their original settings
$Script:Word.Options.CheckGrammarAsYouType = $Script:CurrentGrammarOption
$Script:Word.Options.CheckSpellingAsYouType = $Script:CurrentSpellingOption
Function SetFileName1andFileName2
{
Param([string]$OutputFileName)
$pwdpath = $pwd.Path
If($pwdpath.EndsWith("\"))
{
#remove the trailing \
$pwdpath = $pwdpath.SubString(0, ($pwdpath.Length - 1))
}
If(!$AddDateTime)
{
[string]$Script:FileName1 = "$($pwdpath)\$($OutputFileName).docx"
If($PDF)
{
[string]$Script:FileName2 = "$($pwdpath)\$
($OutputFileName).pdf"
}
}
SetupWord
}
}
#script begins
$Script:StartTime = get-date
If(!(Check-NeededPSSnapins "Citrix.XenApp.Commands")){
#We're missing Citrix Snapins that we need
$ErrorActionPreference = $SaveEAPreference
Write-Error "Missing Citrix PowerShell Snap-ins Detected, check the console
above for more information. Are you sure you are running this script on a XenApp 5
Server? Script will now close."
Exit
}
[string]$FarmName = $farm.FarmName
[string]$Title = "Inventory Report for the $($FarmName) Farm"
SetFileName1andFileName2 "$($farm.FarmName)"
}
Else
{
$ErrorActionPreference = $SaveEAPreference
Write-Warning "Farm information could not be retrieved"
Write-Error "Farm information could not be retrieved. Script cannot
continue."
Exit
}
$farm = $Null
WriteWordLine 2 0 "Farm-wide"
Switch ($Farm.ConnectionAccessControls)
{
"AllowAnyConnection" {WriteWordLine 0 2 "Any connections"}
"AllowOneTypeOnly" {WriteWordLine 0 2 "Citrix Access Gateway,
Citrix XenApp plug-in, and Web Interface connections only"}
"AllowMultipleTypes" {WriteWordLine 0 2 "Citrix Access Gateway
connections only"}
Default {WriteWordLine 0 0 "Connection Access Controls could not
be determined: $($Farm.ConnectionAccessControls)"}
}
If($Farm.ConnectionLimitsLogOverLimits)
{
WriteWordLine 0 3 "Log over-the-limit denials"
}
Else
{
WriteWordLine 0 3 "Do not log over-the-limit denials"
}
$StringMembers = "`n`t`t`t`t`t" +
$Farm.ConfigLogDatabaseConnectionString.replace(";","`n`t`t`t`t`t")
If($Farm.ConfigLogChangesWhileDisconnectedAllowed)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 3 "Require admins to enter database credentials
before clearing the log: " -nonewline
If($Farm.ConfigLogCredentialsOnClearLogRequired)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
Else
{
WriteWordLine 0 2 "Configuration logging is not enabled"
}
$selection.InsertNewPage()
Write-Verbose "$(Get-Date): `tServer Default"
WriteWordLine 2 0 "Server Default"
Write-Verbose "$(Get-Date): `t`tICA"
WriteWordLine 0 1 "ICA"
WriteWordLine 0 2 "Auto Client Reconnect"
If($Farm.AcrEnabled)
{
WriteWordLine 0 3 "Reconnect automatically"
WriteWordLine 0 3 "Log automatic reconnection attempts: "
-NoNewLine
If($Farm.AcrLogReconnections)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
Else
{
WriteWordLine 0 4 "Require user authentication"
}
WriteWordLine 0 2 "Display"
WriteWordLine 0 3 "Discard queued image that is replaced by another
image: " -nonewline
If($Farm.DisplayDiscardQueuedImages)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 3 "Cache image to make scrolling smoother: " -nonewline
If($Farm.DisplayCacheImageForSmoothScrolling)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 3 "Maximum memory to use for each session's graphics
(KB): " $Farm.DisplayMaximumGraphicsMemory
WriteWordLine 0 3 "Degradation bias"
If($Farm.DisplayDegradationBias -eq "Resolution")
{
WriteWordLine 0 4 "Degrade resolution first"
}
Else
{
WriteWordLine 0 4 "Degrade color depth first"
}
WriteWordLine 0 3 "Notify user of session degradation: " -nonewline
If($Farm.DisplayNotifyUser)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "Keep-Alive"
If($Farm.KeepAliveEnabled)
{
WriteWordLine 0 3 "ICA Keep-Alive time-out value (seconds): "
$Farm.KeepAliveTimeout
}
Else
{
WriteWordLine 0 3 "ICA Keep-Alive is not enabled"
}
$Table.Rows.SetLeftIndent($Indent3TabStops,
$wdAdjustProportional)
$Table.AutoFitBehavior($wdAutoFitContent)
FindWordDocumentEnd
}
}
Else
{
WriteWordLine 0 2 "Health Monitoring & Recovery Tests could
not be retrieved"
}
}
Else
{
WriteWordLine 0 2 "Health Monitoring & Recovery is not enabled"
}
If($Farm.FlashAccelerationEnabled)
{
WriteWordLine 0 2 "Enable Adobe Flash Player"
Switch ($Farm.FlashAccelerationOption)
{
"AllConnections" {WriteWordLine 0 3 "Accelerate for
restricted bandwidth connections"}
"Unknown" {WriteWordLine 0 3 "Do not accelerate"}
"NoOptimization" {WriteWordLine 0 3 "Accelerate for all
connections"}
Default {WriteWordLine 0 0 "Server-side acceleration could
not be determined: $($Farm.FlashAccelerationOption)"}
}
}
Else
{
WriteWordLine 0 2 "Adobe Flash is not enabled"
}
If($Farm.MultimediaAccelerationEnabled)
{
WriteWordLine 0 2 "SpeedScreen Multimedia Acceleration is
enabled"
If($Farm.MultimediaAccelerationDefaultBuffer)
{
WriteWordLine 0 3 "Use the Default buffer of 5 seconds"
}
Else
{
WriteWordLine 0 3 "Custom buffer in seconds: "
$Farm.MultimediaAccelerationCustomBuffer
}
}
Else
{
WriteWordLine 0 2 "SpeedScreen Multimedia Acceleration is
disabled"
}
}
ElseIf(!$?)
{
Write-Warning "Farm configuration information could not be retrieved"
}
Else
{
Write-Warning "No results returned for Farm configuration information"
}
$farm = $Null
Write-Verbose "$(Get-Date): Finished getting Farm Configuration data"
Write-Verbose "$(Get-Date): "
}
If($Application.AccessSessionConditionsEnabled)
{
$tmp = @()
ForEach($filter in
$Application.AccessSessionConditions)
{
$tmp += $filter
}
$obj | Add-Member -MemberType NoteProperty
-Name AccessControlFilters -Value $tmp
}
Else
{
$obj | Add-Member -MemberType NoteProperty
-Name AccessControlFilters -Value "None"
}
[bool]$AppServerInfoResults = $False
$AppServerInfo = Get-XAApplicationReport -BrowserName
$Application.BrowserName -EA 0
If($?)
{
$AppServerInfoResults = $True
}
[bool]$streamedapp = $False
If($Application.ApplicationType -Contains
"streamedtoclient" -or $Application.ApplicationType -Contains "streamedtoserver")
{
$streamedapp = $True
}
}
Else
{
$TotalApps++
}
#name properties
If(!$Summary)
{
WriteWordLine 2 0 $Application.DisplayName
WriteWordLine 0 1 "Application name`t`t: "
$Application.BrowserName
WriteWordLine 0 1 "Disable application`t`t: " -NoNewLine
#weird, if application is enabled, it is disabled!
If($Application.Enabled)
{
WriteWordLine 0 0 "No"
}
Else
{
WriteWordLine 0 0 "Yes"
WriteWordLine 0 1 "Hide disabled application`t: "
-nonewline
If($Application.HideWhenDisabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
If(![String]::IsNullOrEmpty($Application.Description))
{
WriteWordLine 0 1 "Application description`t`t: "
$Application.Description
}
#type properties
WriteWordLine 0 1 "Application Type`t`t: " -nonewline
Switch ($Application.ApplicationType)
{
"Unknown" {WriteWordLine 0
0 "Unknown"}
"ServerInstalled" {WriteWordLine 0
0 "Installed application"; $TotalPublishedApps++}
"ServerDesktop" {WriteWordLine 0
0 "Server desktop"; $TotalPublishedDesktops++}
"Content" {WriteWordLine 0
0 "Content"; $TotalPublishedContent++}
"StreamedToServer" {WriteWordLine 0
0 "Streamed to server"; $TotalStreamedApps++}
"StreamedToClient" {WriteWordLine 0
0 "Streamed to client"; $TotalStreamedApps++}
"StreamedToClientOrInstalled" {WriteWordLine 0
0 "Streamed if possible, otherwise accessed from server as Installed application";
$TotalStreamedApps++}
"StreamedToClientOrStreamedToServer" {WriteWordLine 0
0 "Streamed if possible, otherwise Streamed to server"; $TotalStreamedApps++}
Default {WriteWordLine 0 0 "Application Type could
not be determined: $($Application.ApplicationType)"}
}
If(![String]::IsNullOrEmpty($Application.FolderPath))
{
WriteWordLine 0 1 "Folder path`t`t`t: "
$Application.FolderPath
}
If(![String]::IsNullOrEmpty($Application.ContentAddress))
{
WriteWordLine 0 1 "Content Address`t`t: "
$Application.ContentAddress
}
#location properties
If(!$streamedapp)
{
#requested by Pavel Stadler to put Command Line and
Working Directory in a different sized font and make it bold
If(!
[String]::IsNullOrEmpty($Application.CommandLineExecutable))
{
If($Application.CommandLineExecutable.Length
-lt 40)
{
WriteWordLine 0 1 "Command Line`t`t`t: "
-NoNewLine
WriteWordLine 0 0
$Application.CommandLineExecutable "" "Courier New" 9 $False $True
}
Else
{
WriteWordLine 0 1 "Command Line: "
WriteWordLine 0 2
$Application.CommandLineExecutable "" "Courier New" 9 $False $True
}
}
If(!
[String]::IsNullOrEmpty($Application.WorkingDirectory))
{
If($Application.WorkingDirectory.Length -lt 40)
{
WriteWordLine 0 1 "Working directory`t`t:
" -NoNewLine
WriteWordLine 0 0
$Application.WorkingDirectory "" "Courier New" 9 $False $True
}
Else
{
WriteWordLine 0 1 "Working directory: "
WriteWordLine 0 2
$Application.WorkingDirectory "" "Courier New" 9 $False $True
}
}
#servers properties
If($AppServerInfoResults)
{
If(!
[String]::IsNullOrEmpty($AppServerInfo.ServerNames))
{
If(!
[String]::IsNullOrEmpty($AppServerInfo.ServerNames))
{
WriteWordLine 0 1 "Servers:"
$TempArray =
$AppServerInfo.ServerNames | Sort
BuildTableForServer $TempArray
$TempArray = $Null
}
}
}
Else
{
WriteWordLine 0 2 "Unable to retrieve a list of
Servers for this application"
}
}
#users properties
If($Application.AnonymousConnectionsAllowed)
{
WriteWordLine 0 1 "Allow anonymous users: "
$Application.AnonymousConnectionsAllowed
}
Else
{
If($AppServerInfoResults)
{
WriteWordLine 0 1 "Users:"
ForEach($user in $AppServerInfo.Accounts)
{
WriteWordLine 0 2 $user
}
}
Else
{
WriteWordLine 0 2 "Unable to retrieve a list of
Users for this application"
}
}
If($Application.ConnectionsThroughAccessGatewayAllowed)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
If($Application.OtherConnectionsAllowed)
{
WriteWordLine 0 1 "Any connection`t`t`t`t`t: "
-nonewline
If($Application.OtherConnectionsAllowed)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
If($Application.AccessSessionConditionsEnabled)
{
WriteWordLine 0 1 "Any connection that meets any of
the following filters: " $Application.AccessSessionConditionsEnabled
WriteWordLine 0 1 "Access Gateway Filters:"
$TableRange = $doc.Application.Selection.Range
[int]$Columns = 2
[int]$Rows =
$Application.AccessSessionConditions.count + 1
$Table = $doc.Tables.Add($TableRange, $Rows,
$Columns)
$Table.rows.first.headingformat =
$wdHeadingFormatTrue
$Table.Style = $myHash.Word_TableGrid
$Table.Borders.InsideLineStyle = $wdLineStyleSingle
$Table.Borders.OutsideLineStyle = $wdLineStyleSingle
[int]$xRow = 1
Write-Verbose "$(Get-Date): `t`t`t`tFormat first row
with column headings"
$Table.Rows.First.Shading.BackgroundPatternColor =
$wdColorGray15
$Table.Cell($xRow,1).Range.Font.Bold = $True
$Table.Cell($xRow,1).Range.Text = "Farm Name"
$Table.Cell($xRow,2).Range.Font.Bold = $True
$Table.Cell($xRow,2).Range.Text = "Filter"
ForEach($AccessCondition in
$Application.AccessSessionConditions)
{
[string]$Tmp = $AccessCondition
[string]$AGFarm = $Tmp.substring(0,
$Tmp.indexof(":"))
[string]$AGFilter =
$Tmp.substring($Tmp.indexof(":")+1)
$xRow++
Write-Verbose "$(Get-Date):
`t`t`t`t`tProcessing row for Access Condition $($Tmp)"
$Table.Cell($xRow,1).Range.Text = $AGFarm
$Table.Cell($xRow,2).Range.Text = $AGFilter
}
$Table.Rows.SetLeftIndent($Indent2TabStops,
$wdAdjustProportional)
$Table.AutoFitBehavior($wdAutoFitContent)
FindWordDocumentEnd
$tmp = $Null
$AGFarm = $Null
$AGFilter = $Null
}
#limits properties
WriteWordLine 0 1 "Limit instances allowed to run in server
farm`t: " -NoNewLine
If($Application.MultipleInstancesPerUserAllowed)
{
WriteWordLine 0 0 "No"
}
Else
{
WriteWordLine 0 0 "Yes"
}
If($Application.CpuPriorityLevel)
{
WriteWordLine 0 1 "Application importance`t`t`t`t: "
-nonewline
Switch ($Application.CpuPriorityLevel)
{
"Unknown" {WriteWordLine 0 0 "Unknown"}
"BelowNormal" {WriteWordLine 0 0 "Below
Normal"}
"Low" {WriteWordLine 0 0 "Low"}
"Normal" {WriteWordLine 0 0 "Normal"}
"AboveNormal" {WriteWordLine 0 0 "Above
Normal"}
"High" {WriteWordLine 0 0 "High"}
Default {WriteWordLine 0 0 "Application
importance could not be determined: $($Application.CpuPriorityLevel)"}
}
}
#appearance properties
If($Application.WindowType)
{
WriteWordLine 0 1 "Session window size`t`t`t`t: "
$Application.WindowType
}
If($Application.ColorDepth)
{
WriteWordLine 0 1 "Maximum color quality`t`t`t`t: "
-nonewline
Switch ($Application.ColorDepth)
{
"Colors16" {WriteWordLine 0 0 "16 colors"}
"Colors256" {WriteWordLine 0 0 "256 colors"}
"HighColor" {WriteWordLine 0 0 "High Color (16-
bit)"}
"TrueColor" {WriteWordLine 0 0 "True Color (24-
bit)"}
Default {WriteWordLine 0 0 "Maximum color
quality could not be determined: $($Application.ColorDepth)"}
}
}
If($Application.TitleBarHidden)
{
WriteWordLine 0 1 "Hide application title bar`t`t`t:
" -nonewline
If($Application.TitleBarHidden)
{
WriteWordLine 0 0 "Enabled"
}
Else
{
WriteWordLine 0 0 "Disabled"
}
}
If($Application.MaximizedOnStartup)
{
WriteWordLine 0 1 "Maximize application at
startup`t`t`t: " -nonewline
If($Application.MaximizedOnStartup)
{
WriteWordLine 0 0 "Enabled"
}
Else
{
WriteWordLine 0 0 "Disabled"
}
}
$AppServerInfo = $Null
}
Else
{
WriteWordLine 0 0 $Application.DisplayName
}
}
}
ElseIf($Applications -eq $Null)
{
Write-Verbose "$(Get-Date): There are no Applications published"
}
Else
{
Write-Warning "No results returned for Application information"
}
$Applications = $Null
Write-Verbose "$(Get-Date): Finished Processing Applications"
Write-Verbose "$(Get-Date): "
}
If(!$Summary)
{
[bool]$SvrOnline = $False
Write-Verbose "$(Get-Date): `t`t`tTesting to see if $
($server.ServerName) is online and reachable"
If(Test-Connection -ComputerName $server.servername -quiet
-EA 0)
{
$SvrOnline = $True
If($Hardware -and $Software)
{
Write-Verbose "$(Get-Date): `t`t`t`t$
($server.ServerName) is online. Hardware inventory, Software Inventory, Citrix
Services and Hotfix areas will be processed."
}
ElseIf($Hardware -and !($Software))
{
Write-Verbose "$(Get-Date): `t`t`t`t$
($server.ServerName) is online. Hardware inventory, Citrix Services and Hotfix
areas will be processed."
}
ElseIf(!($Hardware) -and $Software)
{
Write-Verbose "$(Get-Date): `t`t`t`t$
($server.ServerName) is online. Software Inventory, Citrix Services and Hotfix
areas will be processed."
}
Else
{
Write-Verbose "$(Get-Date): `t`t`t`t$
($server.ServerName) is online. Citrix Services and Hotfix areas will be
processed."
}
}
WriteWordLine 2 0 $server.ServerName
WriteWordLine 0 1 "Product`t`t`t`t: "
$server.CitrixProductName
WriteWordLine 0 1 "Edition`t`t`t`t: " $server.CitrixEdition
WriteWordLine 0 1 "Version`t`t`t`t: " $server.CitrixVersion
WriteWordLine 0 1 "Service Pack`t`t`t: "
$server.CitrixServicePack
WriteWordLine 0 1 "Operating System Type`t`t: " -NoNewLine
If($server.Is64Bit)
{
WriteWordLine 0 0 "64 bit"
}
Else
{
WriteWordLine 0 0 "32 bit"
}
WriteWordLine 0 1 "IP Address`t`t`t: " $server.IPAddresses
WriteWordLine 0 1 "Logons`t`t`t`t: " -NoNewLine
If($server.LogOnsEnabled)
{
WriteWordLine 0 0 "Enabled"
}
Else
{
WriteWordLine 0 0 "Disabled"
}
WriteWordLine 0 1 "Product Installation Date`t: "
$server.CitrixInstallDate
WriteWordLine 0 1 "Operating System Version`t: "
$server.OSVersion -NoNewLine
$Tmp = "ICA"
If($ServerConfig.AcrUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)\Auto Client
Reconnect: Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)\Auto Client
Reconnect: Server is not using farm settings"
If($ServerConfig.AcrEnabled)
{
WriteWordLine 0 3 "Reconnect
automatically"
WriteWordLine 0 4 "Log automatic
reconnection attempts: " -nonewline
If($ServerConfig.AcrLogReconnections)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
Else
{
WriteWordLine 0 3 "Require user
authentication"
}
}
WriteWordLine 0 2 "$($Tmp)\Browser\Create browser
listener on UDP network: " -nonewline
If($ServerConfig.BrowserUdpListener)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "$($Tmp)\Browser\Server responds to
client broadcast messages: " -nonewline
If($ServerConfig.BrowserRespondToClientBroadcasts)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.DisplayUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)\Display: Server is
using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)\Display: Server is
not using farm settings"
WriteWordLine 0 3 "Discard queued image that is
replaced by another image: " -nonewline
If($ServerConfig.DisplayDiscardQueuedImages)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 3 "Cache image to make
scrolling smoother: " -nonewline
If($ServerConfig.DisplayCacheImageForSmoothScrolling)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 3 "Maximum memory to use for
each session's graphics (KB): " $ServerConfig.DisplayMaximumGraphicsMemory
WriteWordLine 0 3 "Degradation bias: "
If($ServerConfig.DisplayDegradationBias -eq
"Resolution")
{
WriteWordLine 0 4 "Degrade resolution
first"
}
Else
{
WriteWordLine 0 4 "Degrade color depth
first"
}
WriteWordLine 0 3 "Notify user of session
degradation: " -nonewline
If($ServerConfig.DisplayNotifyUser)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
If($ServerConfig.KeepAliveUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)\Keep-Alive: Server
is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)\Keep-Alive: Server
is not using farm settings"
WriteWordLine 0 3 "ICA Keep-Alive time-out
value seconds: " -NoNewLine
If($ServerConfig.KeepAliveEnabled)
{
WriteWordLine 0 0
$ServerConfig.KeepAliveTimeout
}
Else
{
WriteWordLine 0 0 "Disabled"
}
}
If($ServerConfig.PrinterBandwidth -eq -1)
{
WriteWordLine 0 2 "$($Tmp)\Printer
Bandwidth\Unlimited client printer bandwidth"
}
Else
{
WriteWordLine 0 2 "$($Tmp)\Printer
Bandwidth\Limit bandwidth to use (kbps): " $ServerConfig.PrinterBandwidth
}
If($ServerConfig.LicenseServerUseFarmSettings)
{
WriteWordLine 0 2 "License Server: Server is
using farm settings"
}
Else
{
WriteWordLine 0 2 "License Server: Server is
not using farm settings"
WriteWordLine 0 3 "License server name: "
$ServerConfig.LicenseServerName
WriteWordLine 0 3 "License server port: "
$ServerConfig.LicenseServerPortNumber
}
If($ServerConfig.HmrUseFarmSettings)
{
WriteWordLine 0 2 "Health Monitoring &
Recovery: Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "Health Monitoring &
Recovery: Server is not using farm settings"
WriteWordLine 0 3 "Run health monitoring tests
on this server: " -nonewline
If($ServerConfig.HmrEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.HmrEnabled)
{
$HMRTests = Get-XAHmrTest -ServerName
$Server.ServerName -EA 0
If($?)
{
WriteWordLine 0 3 "Health
Monitoring Tests:"
ForEach($HMRTest in $HMRTests)
{
WriteWordLine 0 4 "Test
Name`t: " $Hmrtest.TestName
WriteWordLine 0 4
"Interval`t`t: " $Hmrtest.Interval
WriteWordLine 0 4
"Threshold`t: " $Hmrtest.Threshold
WriteWordLine 0 4 "Time-
out`t: " $Hmrtest.Timeout
WriteWordLine 0 4 "Test File
Name`t: " $Hmrtest.FilePath
If(!
[String]::IsNullOrEmpty($Hmrtest.Arguments))
{
WriteWordLine 0 4
"Arguments`t: " $Hmrtest.Arguments
}
WriteWordLine 0 4 "Recovery
Action : " -nonewline
Switch
($Hmrtest.RecoveryAction)
{
"AlertOnly"
{WriteWordLine 0 0 "Alert Only"}
"RemoveServerFromLoadBal
ancing" {WriteWordLine 0 0 "Remove Server from load balancing"}
"RestartIma"
{WriteWordLine 0 0 "Restart IMA"}
"ShutdownIma"
{WriteWordLine 0 0 "Shutdown IMA"}
"RebootServer"
{WriteWordLine 0 0 "Reboot Server"}
Default {WriteWordLine 0
0 "Recovery Action could not be determined: $($Hmrtest.RecoveryAction)"}
}
WriteWordLine 0 0 ""
}
}
Else
{
WriteWordLine 0 0 "Health
Monitoring & Reporting data could not be retrieved for server " $Server.ServerName
}
}
}
If($ServerConfig.CpuUseFarmSettings)
{
WriteWordLine 0 2 "CPU Utilization Management:
Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "CPU Utilization Management:
Server is not using farm settings"
WriteWordLine 0 3 "CPU Utilization Management:
" -nonewline
Switch ($ServerConfig.CpuManagementLevel)
{
"NoManagement" {WriteWordLine 0 0 "No
CPU utilization management"}
"Fair" {WriteWordLine 0 0 "Fair
sharing of CPU between sessions"}
"ResourceBased" {WriteWordLine 0 0 "CPU
Sharing based on Resource Allotments"}
Default {WriteWordLine 0 0 "CPU
Utilization Management could not be determined: $($Farm.CpuManagementLevel)"}
}
}
If($ServerConfig.MemoryUseFarmSettings)
{
WriteWordLine 0 2 "Memory Optimization: Server
is using farm settings"
}
Else
{
WriteWordLine 0 2 "Memory Optimization: Server
is not using farm settings"
WriteWordLine 0 3 "Memory Optimization: "
-nonewline
If($ServerConfig.MemoryOptimizationEnabled)
{
WriteWordLine 0 0 "Enabled"
}
Else
{
WriteWordLine 0 0 "Not Enabled"
}
}
$Tmp = "XenApp"
If($ServerConfig.ContentRedirectionUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)/Content Redirection:
Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)/Content Redirection:
Server is not using farm settings"
WriteWordLine 0 3 "Content redirection from
server to client: " -nonewline
If($ServerConfig.ContentRedirectionEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
#ShadowLoggingEnabled is not stored by Citrix
#WriteWordLine 0 3 "HDX Plug and Play/Shadow
Logging/Log shadowing sessions: " $ServerConfig.ShadowLoggingEnabled
If($ServerConfig.RemoteConsoleUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)\Remote Console
Connections: Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)\Remote Console
Connections: Server is not using farm settings"
WriteWordLine 0 3 "Remote connections to the
console: " -nonewline
If($ServerConfig.RemoteConsoleEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
If($ServerConfig.SnmpUseFarmSettings)
{
WriteWordLine 0 2 "SNMP: Server is using farm
settings"
}
Else
{
WriteWordLine 0 2 "SNMP: Server is not using
farm settings"
# SnmpEnabled is not working
WriteWordLine 0 3 "Send session traps to
selected SNMP agent on all farm servers"
WriteWordLine 0 4 "SNMP agent session traps:"
WriteWordLine 0 5 "Logon`t`t`t: " -nonewline
If($ServerConfig.SnmpLogOnEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 5 "Logoff`t`t`t: " -nonewline
If($ServerConfig.SnmpLogOffEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 5 "Disconnect`t`t: " -nonewline
If($ServerConfig.SnmpDisconnectEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 5 "Session limit per server`t:
" -nonewline
If($ServerConfig.SnmpLimitEnabled)
{
WriteWordLine 0 0 " "
$ServerConfig.SnmpLimitPerServer
}
Else
{
WriteWordLine 0 0 "No"
}
}
$Tmp = "SpeedScreen"
If($ServerConfig.BrowserAccelerationUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)/Browser
Acceleration: Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)/Browser
Acceleration: Server is not using farm settings"
WriteWordLine 0 3 "$($Tmp)/$($Tmp)Browser
Acceleration: " -nonewline
If($ServerConfig.BrowserAccelerationEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.BrowserAccelerationEnabled)
{
WriteWordLine 0 4 "Compress JPEG images
to improve bandwidth: " -nonewline
If($ServerConfig.BrowserAccelerationCompressionEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.BrowserAccelerationCompressionEnabled)
{
WriteWordLine 0 4 "Image
compression level: " $ServerConfig.BrowserAccelerationCompressionLevel
WriteWordLine 0 4 "Adjust
compression level based on available bandwidth: " -nonewline
If($ServerConfig.BrowserAccelerationVariableImageCompression)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
}
}
$Tmp = "SpeedScreen"
If($ServerConfig.FlashAccelerationUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)/Flash: Server is
using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)/Flash: Server is not
using farm settings"
WriteWordLine 0 3 "Enable Adobe Flash Player: "
-nonewline
If($ServerConfig.FlashAccelerationEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.FlashAccelerationEnabled)
{
Switch
($ServerConfig.FlashAccelerationOption)
{
"RestrictedBandwidth"
{WriteWordLine 0 3 "Restricted bandwidth connections"}
"NoOptimization"
{WriteWordLine 0 3 "Do not optimize"}
"AllConnections"
{WriteWordLine 0 3 "All connections"}
Default {WriteWordLine 0 0 "Server-
side acceleration could not be determined: $
($ServerConfig.FlashAccelerationOption)"}
}
}
}
If($ServerConfig.MultimediaAccelerationUseFarmSettings)
{
WriteWordLine 0 2 "$($Tmp)/Multimedia
Acceleration: Server is using farm settings"
}
Else
{
WriteWordLine 0 2 "$($Tmp)/Multimedia
Acceleration: Server is not using farm settings"
WriteWordLine 0 3 "Multimedia acceleration: "
-nonewline
If($ServerConfig.MultimediaAccelerationEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($ServerConfig.MultimediaAccelerationEnabled)
{
If($ServerConfig.MultimediaAccelerationDefaultBuffer)
{
WriteWordLine 0 3 "Use the Default
buffer of 5 seconds"
}
Else
{
WriteWordLine 0 3 "Custom buffer
time in seconds: " $ServerConfig.MultimediaAccelerationCustomBuffer
}
}
}
WriteWordLine 0 2 "Virtual IP/Enable virtual IP for
this server: " -nonewline
If($ServerConfig.VirtualIPEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "Virtual IP/Use farm setting for IP
address logging: " -nonewline
If($ServerConfig.VirtualIPUseFarmLoggingSettings)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "Virtual IP/Enable logging of IP
address assignment and release: " -nonewline
If($ServerConfig.VirtualIPLoggingEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "Virtual IP/Enable virtual loopback
for this server: " -nonewline
If($ServerConfig.VirtualIPLoopbackEnabled)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "XML Service/Trust requests sent to
the XML service: " -nonewline
If($ServerConfig.XmlServiceTrustRequests)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($Server2008)
{
If($ServerConfig.RestartsEnabled)
{
WriteWordLine 0 2 "Automatic restarts are
enabled"
WriteWordLine 0 3 "Restart server from: "
$ServerConfig.RestartFrom
WriteWordLine 0 3 "Restart frequency in
days: " $ServerConfig.RestartFrequency
}
Else
{
WriteWordLine 0 2 "Automatic restarts are
not enabled"
}
}
WriteWordLine 0 0 ""
}
Else
{
WriteWordLine 0 0 "Server configuration data could
not be retrieved for server " $Server.ServerName
}
If($ServerConfig.LicenseServerUseFarmSettings)
{
$obj | Add-Member -MemberType NoteProperty -Name
LicenseServer -Value "Farm Setting"
}
Else
{
$obj | Add-Member -MemberType NoteProperty -Name
LicenseServer -Value $ServerConfig.LicenseServerName
}
If($SvrOnline)
{
$Reg =
[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',
$server.ServerName)
$RegKey=
$Reg.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Citrix\\Wfshell\\TWI")
$SSDisabled = $RegKey.GetValue("SeamlessFlags")
If($SSDisabled -eq 1)
{
$obj | Add-Member -MemberType NoteProperty
-Name SessionSharing -Value "Disabled"
}
Else
{
$obj | Add-Member -MemberType NoteProperty
-Name SessionSharing -Value "Enabled"
}
}
Else
{
$obj | Add-Member -MemberType NoteProperty -Name
SessionSharing -Value "Server Offline"
}
$ServerItems += $obj
FindWordDocumentEnd
WriteWordLine 0 0 ""
}
$UninstallKey1="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',
$Server.ServerName)
$UninstallKey2="SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstal
l"
$regkey2=$reg.OpenSubKey($UninstallKey2)
If($regkey2 -ne $Null)
{
$subkeys2=$regkey2.GetSubKeyNames()
ForEach($key in $subkeys2)
{
$thisKey=$UninstallKey2+"\\"+$key
$thisSubKey=$reg.OpenSubKey($thisKey)
if(![String]::IsNullOrEmpty($
($thisSubKey.GetValue("DisplayName"))))
{
$obj = New-Object PSObject
$obj | Add-Member -MemberType
NoteProperty -Name "DisplayName" -Value $($thisSubKey.GetValue("DisplayName"))
$obj | Add-Member -MemberType
NoteProperty -Name "DisplayVersion" -Value $
($thisSubKey.GetValue("DisplayVersion"))
$InstalledApps += $obj
}
}
}
$tmp1 = SWExclusions
If($Tmp1 -ne "")
{
$Func = ConvertTo-ScriptBlock $tmp1
$tempapps = Invoke-Command {& $Func}
}
Else
{
$tempapps = $InstalledApps
}
FindWordDocumentEnd
WriteWordLine 0 0 ""
}
Try
{
#Iain Brighton optimization 5-Jun-2014
#Replaced with a single call to retrieve
services via WMI. The repeated
## "Get-WMIObject Win32_Service -Filter" calls
were the major delays in the script.
## If we need to retrieve the StartUp type
might as well just use WMI.
$Services = Get-WMIObject Win32_Service
-ComputerName $server.ServerName -EA 0 | Where {$_.DisplayName -like "*Citrix*"} |
Sort DisplayName
}
Catch
{
$Services = $Null
}
ForEach($Service in $Services)
{
#Write-Verbose "$(Get-Date): `t`t`t
Processing service $($Service.DisplayName)";
$Table.Rows.SetLeftIndent($Indent1TabStops,$wdAdjustProportional)
FindWordDocumentEnd
$Table = $Null
}
}
ElseIf(!$?)
{
Write-Warning "No services were retrieved."
If($MSWord -or $PDF)
{
WriteWordLine 0 0 "Warning: No Services
were retrieved" "" $Null 0 $False $True
WriteWordLine 0 1 "If this is a trusted
Forest, you may need to rerun the" "" $Null 0 $False $True
WriteWordLine 0 1 "script with Admin
credentials from the trusted Forest." "" $Null 0 $False $True
}
}
Else
{
Write-Warning "Services retrieval was
successful but no services were returned."
WriteWordLine 0 0 "Services retrieval was
successful but no services were returned." "" $Null 0 $False $True
}
Catch
{
$hotfixes = $Null
}
ForEach($hotfix in $hotfixes)
{
$HotfixArray += $hotfix.HotfixName
$InstallDate =
$hotfix.InstalledOn.ToString()
$CurrentServiceIndex++;
}
}
$Table.Rows.SetLeftIndent($Indent1TabStops,$wdAdjustProportional)
FindWordDocumentEnd
$Table = $Null
WriteWordLine 0 0 ""
}
}
ElseIf(!$?)
{
Write-Warning "No Citrix hotfixes were
retrieved"
If($MSWORD -or $PDF)
{
WriteWordLine 0 0 "Warning: No Citrix
hotfixes were retrieved" "" $Null 0 $False $True
}
}
Else
{
Write-Warning "Citrix hotfix retrieval was
successful but no Citrix hotfixes were returned."
If($MSWORD -or $PDF)
{
WriteWordLine 0 0 "Citrix hotfix
retrieval was successful but no Citrix hotfixes were returned." "" $Null 0 $False
$True
}
}
}
Else
{
Write-Verbose "$(Get-Date): `t`t$($server.ServerName)
is offline or unreachable. Citrix Services and Hotfix areas skipped."
WriteWordLine 0 0 "Server $($server.ServerName) was
offline or unreachable at "$(Get-Date -Format u)
WriteWordLine 0 0 "The Citrix Services and Hotfix
areas were skipped."
}
WriteWordLine 0 0 ""
Write-Verbose "$(Get-Date): `t`t`tFinished Processing
server $($server.ServerName)"
Write-Verbose "$(Get-Date): "
}
Else
{
WriteWordLine 0 0 $server.ServerName
}
}
}
ElseIf(!$?)
{
Write-Warning "Server information could not be retrieved"
}
Else
{
Write-Warning "No results returned for Server information"
}
$servers = $Null
Write-Verbose "$(Get-Date): Finished Processing Servers"
Write-Verbose "$(Get-Date): "
}
$selection.InsertNewPage()
WriteWordLine 1 0 "Zones:"
ForEach($Zone in $Zones)
{
$TotalZones++
Write-Verbose "$(Get-Date): `t`tProcessing zone $
($Zone.ZoneName)"
If(!$Summary)
{
WriteWordLine 2 0 $Zone.ZoneName
WriteWordLine 0 1 "Current Data Collector: "
$Zone.DataCollector
$Servers = Get-XAServer -ZoneName $Zone.ZoneName -EA 0 |
Sort ElectionPreference, ServerName
If($? -and $Servers -ne $Null)
{
WriteWordLine 0 1 "Servers in Zone"
ForEach($Server in $Servers)
{
WriteWordLine 0 2 "Server Name and Preference:
" $server.ServerName -NoNewLine
WriteWordLine 0 0 " - " -nonewline
Switch ($server.ElectionPreference)
{
"Unknown" {WriteWordLine 0 0
"Unknown"}
"MostPreferred" {WriteWordLine 0 0
"Most Preferred"}
"Preferred" {WriteWordLine 0 0
"Preferred"}
"DefaultPreference" {WriteWordLine 0 0
"Default Preference"}
"NotPreferred" {WriteWordLine 0 0
"Not Preferred"}
"WorkerMode" {WriteWordLine 0 0
"Worker Mode"}
Default {WriteWordLine 0 0 "Zone
preference could not be determined: $($server.ElectionPreference)"}
}
}
}
Else
{
WriteWordLine 0 1 "Unable to enumerate servers in the
zone"
}
$Servers = $Null
}
Else
{
WriteWordLine 0 0 $Zone.ZoneName
}
}
If($LoadEvaluator.IsBuiltIn)
{
WriteWordLine 0 1 "Built-in Load Evaluator"
}
Else
{
WriteWordLine 0 1 "User created load evaluator"
}
If($LoadEvaluator.ApplicationUserLoadEnabled)
{
WriteWordLine 0 1 "Application User Load Settings"
WriteWordLine 0 2 "Report full load when the # of
users for this application =: " $LoadEvaluator.ApplicationUserLoad
WriteWordLine 0 2 "Application: "
$LoadEvaluator.ApplicationBrowserName
}
If($LoadEvaluator.ContextSwitchesEnabled)
{
WriteWordLine 0 1 "Context Switches Settings"
WriteWordLine 0 2 "Report full load when the # of
context Switches per second is >= than: " $LoadEvaluator.ContextSwitches[1]
WriteWordLine 0 2 "Report no load when the # of
context Switches per second is <= to: " $LoadEvaluator.ContextSwitches[0]
}
If($LoadEvaluator.CpuUtilizationEnabled)
{
WriteWordLine 0 1 "CPU Utilization Settings"
WriteWordLine 0 2 "Report full load when the
processor utilization % is > than: " $LoadEvaluator.CpuUtilization[1]
WriteWordLine 0 2 "Report no load when the processor
utilization % is <= to: " $LoadEvaluator.CpuUtilization[0]
}
If($LoadEvaluator.DiskDataIOEnabled)
{
WriteWordLine 0 1 "Disk Data I/O Settings"
WriteWordLine 0 2 "Report full load when the total
disk I/O in kbps > than: " $LoadEvaluator.DiskDataIO[1]
WriteWordLine 0 2 "Report no load when the total disk
I/O in kbps <= to: " $LoadEvaluator.DiskDataIO[0]
}
If($LoadEvaluator.DiskOperationsEnabled)
{
WriteWordLine 0 1 "Disk Operations Settings"
WriteWordLine 0 2 "Report full load when the total #
of R/W operations per second is > than: " $LoadEvaluator.DiskOperations[1]
WriteWordLine 0 2 "Report no load when the total # of
R/W operations per second is <= to: " $LoadEvaluator.DiskOperations[0]
}
If($LoadEvaluator.IPRangesEnabled)
{
WriteWordLine 0 1 "IP Range Settings"
If($LoadEvaluator.IPRangesAllowed)
{
WriteWordLine 0 2 "Allow " -NoNewLine
}
Else
{
WriteWordLine 0 2 "Deny " -NoNewLine
}
WriteWordLine 0 2 "client connections from the listed
IP Ranges"
ForEach($IPRange in $LoadEvaluator.IPRanges)
{
WriteWordLine 0 4 "IP Address Ranges: "
$IPRange
}
}
If($LoadEvaluator.LoadThrottlingEnabled)
{
WriteWordLine 0 1 "Load Throttling Settings"
WriteWordLine 0 2 "Impact of logons on load: "
-nonewline
Switch ($LoadEvaluator.LoadThrottling)
{
"Unknown" {WriteWordLine 0 0 "Unknown"}
"Extreme" {WriteWordLine 0 0 "Extreme"}
"High" {WriteWordLine 0 0 "High
(Default)"}
"MediumHigh" {WriteWordLine 0 0 "Medium High"}
"Medium" {WriteWordLine 0 0 "Medium"}
"MediumLow" {WriteWordLine 0 0 "Medium Low"}
Default {WriteWordLine 0 0 "Impact of logons on
load could not be determined: $($LoadEvaluator.LoadThrottling)"}
}
}
If($LoadEvaluator.MemoryUsageEnabled)
{
WriteWordLine 0 1 "Memory Usage Settings"
WriteWordLine 0 2 "Report full load when the memory
usage is > than: " $LoadEvaluator.MemoryUsage[1]
WriteWordLine 0 2 "Report no load when the memory
usage is <= to: " $LoadEvaluator.MemoryUsage[0]
}
If($LoadEvaluator.PageFaultsEnabled)
{
WriteWordLine 0 1 "Page Faults Settings"
WriteWordLine 0 2 "Report full load when the # of
page faults per second is > than: " $LoadEvaluator.PageFaults[1]
WriteWordLine 0 2 "Report no load when the # of page
faults per second is <= to: " $LoadEvaluator.PageFaults[0]
}
If($LoadEvaluator.PageSwapsEnabled)
{
WriteWordLine 0 1 "Page Swaps Settings"
WriteWordLine 0 2 "Report full load when the # of
page swaps per second is > than: " $LoadEvaluator.PageSwaps[1]
WriteWordLine 0 2 "Report no load when the # of page
swaps per second is <= to: " $LoadEvaluator.PageSwaps[0]
}
If($LoadEvaluator.ScheduleEnabled)
{
WriteWordLine 0 1 "Scheduling Settings"
WriteWordLine 0 2 "Sunday Schedule`t: "
$LoadEvaluator.SundaySchedule
WriteWordLine 0 2 "Monday Schedule`t: "
$LoadEvaluator.MondaySchedule
WriteWordLine 0 2 "Tuesday Schedule`t: "
$LoadEvaluator.TuesdaySchedule
WriteWordLine 0 2 "Wednesday Schedule`t: "
$LoadEvaluator.WednesdaySchedule
WriteWordLine 0 2 "Thursday Schedule`t: "
$LoadEvaluator.ThursdaySchedule
WriteWordLine 0 2 "Friday Schedule`t`t: "
$LoadEvaluator.FridaySchedule
WriteWordLine 0 2 "Saturday Schedule`t: "
$LoadEvaluator.SaturdaySchedule
}
If($LoadEvaluator.ServerUserLoadEnabled)
{
WriteWordLine 0 1 "Server User Load Settings"
WriteWordLine 0 2 "Report full load when the # of
server users equals: " $LoadEvaluator.ServerUserLoad
}
WriteWordLine 0 0 ""
}
Else
{
WriteWordLine 0 0 $LoadEvaluator.LoadEvaluatorName
}
}
}
ElseIf(!$?)
{
Write-Warning "Load Evaluator information could not be retrieved"
}
Else
{
Write-Warning "No results returned for Load Evaluator information"
}
$LoadEvaluators = $Null
Write-Verbose "$(Get-Date): Finished Processing Load Evaluators"
Write-Verbose "$(Get-Date): "
}
If($Filter.AccessControlEnabled)
{
If($Filter.AllowConnectionsThroughAccessGateway)
{
WriteWordLine 0 2 "Apply to
connections made through Access Gateway"
If($Filter.AccessSessionConditions)
{
WriteWordLine 0 3 "Any
connection that meets any of the following filters"
$TableRange =
$doc.Application.Selection.Range
[int]$Columns = 2
[int]$Rows =
$Filter.AccessSessionConditions.count + 1
$Table =
$doc.Tables.Add($TableRange, $Rows, $Columns)
$Table.rows.first.headingformat = $wdHeadingFormatTrue
$Table.Style =
$myHash.Word_TableGrid
$Table.Borders.InsideLineStyle = $wdLineStyleSingle
$Table.Borders.OutsideLineStyle = $wdLineStyleSingle
[int]$xRow = 1
Write-Verbose "$(Get-Date):
`t`t`t`tFormat first row with column headings"
$Table.Rows.First.Shading.BackgroundPatternColor = $wdColorGray15
$Table.Cell($xRow,1).Range.Font.Bold = $True
$Table.Cell($xRow,2).Range.Font.Bold = $True
$Table.Cell($xRow,2).Range.Text = "Filter"
ForEach($AccessCondition in
$Filter.AccessSessionConditions)
{
[string]$Tmp =
$AccessCondition
[string]$AGFarm =
$Tmp.substring(0, $Tmp.indexof(":"))
[string]$AGFilter =
$Tmp.substring($Tmp.indexof(":")+1)
$xRow++
Write-Verbose "$(Get-
Date): `t`t`t`t`tProcessing row for Access Condition $($Tmp)"
$Table.Cell($xRow,1).Range.Text = $AGFarm
$Table.Cell($xRow,2).Range.Text = $AGFilter
}
$Table.Rows.SetLeftIndent($Indent3TabStops,$wdAdjustProportional)
$Table.AutoFitBehavior($wdAutoFitContent)
FindWordDocumentEnd
$tmp = $Null
$AGFarm = $Null
$AGFilter = $Null
}
Else
{
WriteWordLine 0 3 "Any
connection"
}
WriteWordLine 0 3 "Apply to all
other connections: " -nonewline
If($Filter.AllowOtherConnections)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
}
Else
{
WriteWordLine 0 2 "Do not apply to
connections made through Access Gateway"
}
}
If($Filter.ClientIPAddressEnabled)
{
WriteWordLine 0 2 "Apply to all client IP
addresses: " -nonewline
If($Filter.ApplyToAllClientIPAddresses)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($Filter.AllowedIPAddresses)
{
WriteWordLine 0 2 "Allowed IP
Addresses:"
ForEach($Allowed in
$Filter.AllowedIPAddresses)
{
WriteWordLine 0 3 $Allowed
}
}
If($Filter.DeniedIPAddresses)
{
WriteWordLine 0 2 "Denied IP
Addresses:"
ForEach($Denied in
$Filter.DeniedIPAddresses)
{
WriteWordLine 0 3 $Denied
}
}
}
If($Filter.ClientNameEnabled)
{
WriteWordLine 0 2 "Apply to all client
names: " -nonewline
If($Filter.ApplyToAllClientNames)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($Filter.AllowedClientNames)
{
WriteWordLine 0 2 "Allowed Client
Names:"
ForEach($Allowed in
$Filter.AllowedClientNames)
{
WriteWordLine 0 3 $Allowed
}
}
If($Filter.DeniedClientNames)
{
WriteWordLine 0 2 "Denied Client
Names:"
ForEach($Denied in
$Filter.DeniedClientNames)
{
WriteWordLine 0 3 $Denied
}
}
}
If($Filter.ServerEnabled)
{
If($Filter.AllowedServerNames)
{
WriteWordLine 0 2 "Allowed Server
Names:"
ForEach($Allowed in
$Filter.AllowedServerNames)
{
WriteWordLine 0 3 $Allowed
}
}
If($Filter.DeniedServerNames)
{
WriteWordLine 0 2 "Denied Server
Names:"
ForEach($Denied in
$Filter.DeniedServerNames)
{
WriteWordLine 0 3 $Denied
}
}
If($Filter.AllowedServerFolders)
{
WriteWordLine 0 2 "Allowed Server
Folders:"
ForEach($Allowed in
$Filter.AllowedServerFolders)
{
WriteWordLine 0 3 $Allowed
}
}
If($Filter.DeniedServerFolders)
{
WriteWordLine 0 2 "Denied Server
Folders:"
ForEach($Denied in
$Filter.DeniedServerFolders)
{
WriteWordLine 0 3 $Denied
}
}
}
If($Filter.AccountEnabled)
{
WriteWordLine 0 2 "Apply to all explicit
(non-anonymous) users: " -nonewline
If($Filter.ApplyToAllExplicitAccounts)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
WriteWordLine 0 2 "Apply to anonymous
users: " -nonewline
If($Filter.ApplyToAnonymousAccounts)
{
WriteWordLine 0 0 "Yes"
}
Else
{
WriteWordLine 0 0 "No"
}
If($Filter.AllowedAccounts)
{
WriteWordLine 0 2 "Allowed
Accounts:"
ForEach($Allowed in
$Filter.AllowedAccounts)
{
WriteWordLine 0 3 $Allowed
}
}
If($Filter.DeniedAccounts)
{
WriteWordLine 0 2 "Denied
Accounts:"
ForEach($Denied in
$Filter.DeniedAccounts)
{
WriteWordLine 0 3 $Denied
}
}
}
}
Else
{
WriteWordLine 0 1 "No filter information"
}
}
ElseIf(!$?)
{
WriteWordLine 0 1 "Unable to retrieve Filter
settings"
}
Else
{
WriteWordLine 0 1 "No Filter settings were found"
}
$Settings = $Null
$Filter = $Null
Write-Verbose "$(Get-Date): `t`tFinished Processing policy
$($Policy.PolicyName)"
Write-Verbose "$(Get-Date): "
}
Else
{
WriteWordLine 0 0 $Policy.PolicyName
}
}
}
ElseIf($Policies -eq $Null)
{
Write-Verbose "$(Get-Date): There are no Policies created"
}
Else
{
Write-Warning "No results returned for Citrix Policy information"
}
$Policies = $Null
Write-Verbose "$(Get-Date): Finished Processing Policies"
Write-Verbose "$(Get-Date): "
}
FindWordDocumentEnd
}
ElseIf($PrinterDrivers -eq $Null)
{
Write-Verbose "$(Get-Date): There are no Printer Drivers created"
}
Else
{
Write-Warning "No results returned for Printer driver information"
}
$PrintDrivers = $Null
Write-Verbose "$(Get-Date): Finished Processing Print Drivers"
Write-Verbose "$(Get-Date): "
FindWordDocumentEnd
}
ElseIf($PrinterDriverMappings -eq $Null)
{
Write-Verbose "$(Get-Date): There are no Printer Driver Mappings
created"
}
Else
{
Write-Warning "No results returned for Printer driver mapping
information"
}
$PrintDriverMappings = $Null
Write-Verbose "$(Get-Date): Finished Processing Printer Driver Mappings"
Write-Verbose "$(Get-Date): "
}
$Table.Cell($xRow,1).Shading.BackgroundPatternColor = $wdColorGray05
$Table.Cell($xRow,2).Shading.BackgroundPatternColor = $wdColorGray05
$Table.Cell($xRow,3).Shading.BackgroundPatternColor = $wdColorGray05
$Table.Cell($xRow,4).Shading.BackgroundPatternColor = $wdColorGray05
$Table.Cell($xRow,5).Shading.BackgroundPatternColor = $wdColorGray05
$Table.Cell($xRow,6).Shading.BackgroundPatternColor = $wdColorGray05
}
$Table.Cell($xRow,1).Range.Font.size = 9
$Table.Cell($xRow,1).Range.Text = $Item.Date
$Table.Cell($xRow,2).Range.Font.size = 9
$Table.Cell($xRow,2).Range.Text = $Item.Account
$Table.Cell($xRow,3).Range.Font.size = 9
$Table.Cell($xRow,3).Range.Text = $Item.Description
$Table.Cell($xRow,4).Range.Font.size = 9
$Table.Cell($xRow,4).Range.Text = $Item.TaskType
$Table.Cell($xRow,5).Range.Font.size = 9
$Table.Cell($xRow,5).Range.Text = $Item.ItemType
$Table.Cell($xRow,6).Range.Font.size = 9
$Table.Cell($xRow,6).Range.Text = $Item.ItemName
}
$Table.AutoFitBehavior($wdAutoFitContent)
FindWordDocumentEnd
}
Else
{
WriteWordLine 0 0 "Configuration log report could not be
retrieved"
}
$ConfigLogReport = $Null
}
Else
{
$selection.InsertNewPage()
WriteWordLine 1 0 "Configuration Logging is enabled but the
XA5ConfigLog.udl file was not found"
}
Write-Verbose "$(Get-Date): Finished Processing the Configuration
Logging Report"
}
}
Write-Verbose "$(Get-Date): "
ForEach($Item in $SessionSharingItems)
{
If($MSWord -or $PDF)
{
## Add the required key/values to the hashtable
$WordTableRowHash = @{ ApplicationName = $Item.ApplicationName;
MaximumColorQuality = $Item.MaximumColorQuality;
SessionWindowSize = $Item.SessionWindowSize;
AccessControlFilters = $Item.AccessControlFilters;
Encryption = $Item.Encryption}
$CurrentServiceIndex++;
}
}
$Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
FindWordDocumentEnd
$TableRange = $Null
$Table = $Null
}
ForEach($Item in $ServerItems)
{
$Tmp = $Null
If([String]::IsNullOrEmpty($Item.LicenseServer))
{
$Tmp = "Set by policy"
}
Else
{
$Tmp = $Item.LicenseServer
}
If($MSWord -or $PDF)
{
## Add the required key/values to the hashtable
$WordTableRowHash = @{ ServerName = $Item.ServerName;
ZoneName = $Item.ZoneName;
OSVersion = $Item.OSVersion;
CitrixVersion = $Item.CitrixVersion;
ProductEdition = $Item.ProductEdition;
LicenseServer = $Tmp
SessionSharing = $Item.SessionSharing}
## Add the hash to the array
$ItemsWordTable += $WordTableRowHash;
$CurrentServiceIndex++;
}
}
$Table.Rows.SetLeftIndent($Indent0TabStops,$wdAdjustProportional)
FindWordDocumentEnd
$Table = $Null
}
If($PDF)
{
If(Test-Path "$($Script:FileName2)")
{
Write-Verbose "$(Get-Date): $($Script:FileName2) is ready for use"
}
Else
{
Write-Warning "$(Get-Date): Unable to save the output file, $
($Script:FileName2)"
Write-Error "Unable to save the output file, $($Script:FileName2)"
}
}
Else
{
If(Test-Path "$($Script:FileName1)")
{
Write-Verbose "$(Get-Date): $($Script:FileName1) is ready for use"
}
Else
{
Write-Warning "$(Get-Date): Unable to save the output file, $
($Script:FileName1)"
Write-Error "Unable to save the output file, $($Script:FileName1)"
}
}