• XenApp 6.0 Documentation Script has been Updated 21-JAN-2013

    Recently I updated my XenApp 6.5 documentation script and in doing so discovered several issues that needed to be resolved in the XenApp 6 script.

    For the XenApp 6.5 script, Andrew Morgan added a Function to the script to make sure the three required PowerShell snap-ins are loaded.

    Function Check-NeededPSSnapins
    {
        Param( [parameter(Mandatory = $true)][alias("Snapin")][string[]]$Snapins)
    
        #function specifics
        $MissingSnapins=@()
        $FoundMissingSnapin=$false
    
        #Creates arrays of strings, rather than objects, we're passing strings so this will be more robust.
        $loadedSnapins += get-pssnapin | % {$_.name}
        $registeredSnapins += get-pssnapin -Registered | % {$_.name}
    
        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
                }#End Registered If
    
                Else{
                    #Snapin is registered, but not loaded, loading it now:
                    Write-Host "Loading Windows PowerShell snap-in: $snapin"
                    Add-PSSnapin -Name $snapin
                }
    
            }#End Loaded If
            #Snapin is registered and loaded
            else{write-debug "Windows PowerShell snap-in: $snapin - Already Loaded"}
        }#End For
    
        if ($FoundMissingSnapin){
            write-warning "Missing Windows PowerShell snap-ins Detected:"
            $missingSnapins | % {write-warning "($_)"}
            return $False
        }#End If
    
        Else{
            Return $true
        }#End Else
    
    }#End Function
    

    At the beginning of the script, we check for the required snap-ins.

    if (!(Check-NeededPSSnapins "Citrix.Common.Commands","Citrix.Common.GroupPolicy","Citrix.XenApp.Commands")){
        #We're missing Citrix Snapins that we need
        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 6 Server? Script will now close."
        break
    }
    

    If the snap-ins do not exist because the script is not being run on a XenApp 6 server, we get the following.

    WARNING: Missing Windows PowerShell snap-ins Detected:
    WARNING: (Citrix.Common.Commands)
    WARNING: (Citrix.Common.GroupPolicy)
    WARNING: (Citrix.XenApp.Commands)
    E:\test.ps1 : Missing Citrix PowerShell Snap-ins Detected, check the console above for more information. Are you sure y
    ou are running this script on a XenApp 6 Server? Script will now close.
    At line:1 char:11
    + .\test.ps1 <<<<
        + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
        + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,test.ps1
    

    If the snap-ins are not loaded in the current PowerShell session, they are loaded.

    Loading Windows PowerShell snap-in: Citrix.Common.Commands
    Loading Windows PowerShell snap-in: Citrix.Common.GroupPolicy
    Loading Windows PowerShell snap-in: Citrix.XenApp.Commands
    

    The original script would just stop working if the Citrix.GroupPolicy.Commands module was not loaded into the current PowerShell session before the script was run. Jeff Wouters supplied a function to make sure the Citrix.GroupPolicy.Commands module was loaded. Michael B. Smith modified the function so it worked if the module is not installed on the server. And Andrew Morgan suggested an improvement to MBS’ update to make it even better.

    Function Check-LoadedModule
    #function created by Jeff Wouters
    #@JeffWouters on Twitter
    #modified by Michael B. Smith to handle when the module doesn't exist on server
    #modified by @andyjmorgan
    #This function handles all three scenarios:
    #
    # 1. Module is already imported into current session
    # 2. Module is not already imported into current session, it does exists on the server and is imported
    # 3. Module does not exist on the server
    
    {
    	Param( [parameter(Mandatory = $true)][alias("Module")][string]$ModuleName)
    	#$LoadedModules = Get-Module | Select Name
    	#following line changed at the recommendation of @andyjmorgan
    	$LoadedModules = Get-Module |% { $_.Name.ToString() }
    	$ModuleFound = (!$LoadedModules -like "*$ModuleName*")
    	if (!$ModuleFound)
    	{
    		$module = Import-Module -Name $ModuleName –PassThru –EA 0
    		If( $module –and $? )
    		{
    			# module imported properly
    			Return $True
    		}
    		Else
    		{
    			# module import failed
    			Return $False
    		}
    	}
    	Else
    	{
    		#module already imported into current session
    		Return $true
    	}
    }
    

    If the Citrix.GroupPolicy.Commands module is already loaded into the current session, the script continues. If the Citrix.GroupPolicy.Commands module is not loaded into the current session and the module exists on the server, the module is loaded and the script continues. If the Citrix.GroupPolicy.Commands module does not exist on the server, the script will issue a warning and ends gracefully. Citrix farm policy processing is the last thing the script does.

    WARNING: The Citrix Group Policy module Citrix.GroupPolicy.Commands.psm1 does not exist
    (http://support.citrix.com/article/CTX128625), Citrix Policy documentation will not take place.
    

    There were several fixes made to the Policies section:

    • Policies are now sorted by Type and Priority
    • Fixed policy filters not working
    • Fixed missing policy entries for:
      • Memory optimization exclusion list
      • Offline app users
      • Virtual IP compatibility programs list
      • Virtual IP filter adapter addresses programs list
      • Virtual IP virtual loopback programs list
      • Flash server-side content fetching whitelist
      • Printer driver mapping and compatibility
      • Users who can shadow other users
      • Users who cannot shadow other users
      • Client USB device redirection rules

    Policies are now sorted by Type and Priority instead of Policy Name. This allows the output to match what is shown in AppCenter.

    I found out that the Policy Filter code just did not work. That is now fixed and will handle multiple filters.

    $filters = Get-CtxGroupPolicyFilter -PolicyName $Policy.PolicyName -EA 0
    
    If( $? )
    {
    	If(![String]::IsNullOrEmpty($filters))
    	{
    		line 2 "Filter(s):"
    		ForEach($Filter in $Filters)
    		{
    			Line 3 "Filter name   : " $filter.FilterName
    			Line 3 "Filter type   : " $filter.FilterType
    			Line 3 "Filter enabled: " $filter.Enabled
    			Line 3 "Filter mode   : " $filter.Mode
    			Line 3 "Filter value  : " $filter.FilterValue
    			Line 3 ""
    		}
    	}
    	Else
    	{
    		line 2 "No filter information"
    	}
    }
    Else
    {
    	Line 2 "Unable to retrieve Filter settings"
    }
    

    Original script output:

    Policies:
            Policy Name: Every Possible Computer Setting
                    Type: Computer
                    Description:
                    Enabled: True
                    Priority: 2
                    No filter information
    
            Policy Name: Every User Setting
                    Type: User
                    Description: Every user policy setting
                    Enabled: True
                    Priority: 2
                    No filter information
    

    Updated script output:

    Policy Name   : Every Possible Computer Setting
             Type          : Computer
             Description   :
             Enabled       : True
             Priority      : 2
             Filter(s):
                     Filter name   : ServerGroupFilter0
                     Filter type   : WorkerGroup
                     Filter enabled: True
                     Filter mode   : Allow
                     Filter value  : TestWG
    
                     Filter name   : ServerGroupFilter1
                     Filter type   : WorkerGroup
                     Filter enabled: True
                     Filter mode   : Allow
                     Filter value  : testwg2
    
    Policy Name   : Every User Setting
            Type          : User
            Description   : Every user policy setting
            Enabled       : True
            Priority      : 2
            Filter(s):
                    Filter name   : ClientNameFilter0
                    Filter type   : ClientName
                    Filter enabled: True
                    Filter mode   : Allow
                    Filter value  : ClientName
    
                    Filter name   : ClientIPFilter0
                    Filter type   : ClientIP
                    Filter enabled: True
                    Filter mode   : Allow
                    Filter value  : 192.168.1.1
    

    Turns out the missing policy entries were stored as arrays. MBS helped me figure this out by looking at one item, OfflineUsers.

    PS C:\webster> $Setting = Get-CtxGroupPolicyConfiguration -PolicyName "Every Possible Computer Setting"
    PS C:\webster> $setting
    
    PolicyName   : Every Possible Computer Setting
    Type         : Computer
    OfflineUsers : @{State=Enabled; Values=System.Object[]; Path=ServerSettings\OfflineApplications\OfflineUsers}
    

    The Values=System.Object[] means the data is stored in an array. By running the following PowerShell code we can see the data.

    PS C:\webster> $array = $Setting.OfflineUsers.Values
    PS C:\webster> foreach( $element in $array)
    >> {
    >>     echo $element
    >> }
    >>
    XA60\Anon000
    XA60\Anon001
    PS C:\webster>
    

    I did that for all the items I thought had missing data:
    • Memory optimization exclusion list
    • Offline app users
    • Virtual IP compatibility programs list
    • Virtual IP filter adapter addresses programs list
    • Virtual IP virtual loopback programs list
    • Flash server-side content fetching whitelist
    • Printer driver mapping and compatibility
    • Users who can shadow other users
    • Users who cannot shadow other users
    • Client USB device redirection rules

    The PowerShell code is exactly the same for each.

    The Policies section is over 800 lines long so you can look at the script itself to see all the changes made.

    Original script output:

    Policies:
            Policy Name: Test for Updated Script computer policies
                    Type: Computer
                    Description:
                    Enabled: True
                    Priority: 2
                    No filter information
                    Computer settings:
                            Server Settings\Memory/CPU\Memory optimization exclusion list - Value:
                            Server Settings\Offline Applications\Offline app users - Value:
                            Virtual IP\Virtual IP compatibility programs list - Value:
                            Virtual IP\Virtual IP filter adapter addresses programs list - Value:
                            Virtual IP\Virtual IP virtual loopback programs list - Value:
    
            Policy Name: Test for updated script user policies
                    Type: User
                    Description:
                    Enabled: True
                    Priority: 2
                    No filter information
                    User settings:
                            ICA\Multimedia\HDX MediaStream for Flash (client side)\Flash server-side content fetching whitelist - Value:
                            ICA\Printing\Drivers\Printer driver mapping and compatibility - Value: Enabled
                            ICA\Shadowing\Users who can shadow other users - Value:
                            ICA\Shadowing\Users who cannot shadow other users - Value:
                            ICA\USB devices\Client USB device redirection rules - Value:
    
            Policy Name: Unfiltered
                    Type: Computer
                    Description:
                    Enabled: True
                    Priority: 1
                    No filter information
                    Computer settings:
                    User settings:
    
            Policy Name: Unfiltered
                    Type: User
                    Description:
                    Enabled: True
                    Priority: 1
                    No filter information
                    Computer settings:
                    User settings:
    

    Updated script output:

    Policies:
            Policy Name: Unfiltered
                    Type: Computer
                    Description:
                    Enabled: True
                    Priority: 1
                    No filter information
                    Computer settings:
                    User settings:
    
            Policy Name: Test for Updated Script computer policies
                    Type: Computer
                    Description:
                    Enabled: True
                    Priority: 2
                    Filter(s):
                            Filter name   : ServerGroupFilter0
                            Filter type   : WorkerGroup
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : test1
    
                            Filter name   : ServerGroupFilter1
                            Filter type   : WorkerGroup
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : test2
    
                    Computer settings:
                            Server Settings\Memory/CPU\Memory optimization exclusion list - Values:
                                    webster.exe
                                    notepad.exe
                                    wordpad.exe
                            Server Settings\Offline Applications\Offline app users:
                                    XA60\Anon001
                                    XA60\Anon000
                                    XA60\Anon002
                            Virtual IP\Virtual IP compatibility programs list - Values:
                                    webster.exe
                                    notepad.exe
                                    wordpad.exe
                            Virtual IP\Virtual IP filter adapter addresses programs list - Values:
                                    outlook.exe
                                    word.exe
                                    excel.exe
                            Virtual IP\Virtual IP virtual loopback programs list - Values:
                                    wordpad.exe
                                    webster.exe
                                    notepad.exe
    
            Policy Name: Unfiltered
                    Type: User
                    Description:
                    Enabled: True
                    Priority: 1
                    No filter information
                    Computer settings:
                    User settings:
    
            Policy Name: Test for updated script user policies
                    Type: User
                    Description:
                    Enabled: True
                    Priority: 2
                    Filter(s):
                            Filter name   : UserFilter0
                            Filter type   : User
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : XA60\Anon000
    
                            Filter name   : ServerGroupFilter0
                            Filter type   : WorkerGroup
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : test1
    
                            Filter name   : ClientNameFilter0
                            Filter type   : ClientName
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : ClientName
    
                            Filter name   : ClientIPFilter0
                            Filter type   : ClientIP
                            Filter enabled: True
                            Filter mode   : Allow
                            Filter value  : 192.168.1.1
    
                    User settings:
                            ICA\Multimedia\HDX MediaStream for Flash (client side)\Flash server-side content fetching whitelist - Values:
                                    carlwebster.com
                                    citrix.com
                                    flash.com
                            ICA\Printing\Drivers\Printer driver mapping and compatibility - Value:
                                    webster,Allow
                                    joe,Deny
                                    tom,UPD_Only
                                    sillygoose,Replace=Citrix Universal Printer
                            ICA\Shadowing\Users who can shadow other users:
                                    0x05/NT/XA60\ANON000/S-1-5-21-3142409717-2937184998-2425403696-1005
                                    0x05/NT/XA60\ANON002/S-1-5-21-3142409717-2937184998-2425403696-1007
                                    0x05/NT/XA60\ANON004/S-1-5-21-3142409717-2937184998-2425403696-1009
                                    0x05/NT/XA60\ANON006/S-1-5-21-3142409717-2937184998-2425403696-1011
                                    0x05/NT/XA60\ANON008/S-1-5-21-3142409717-2937184998-2425403696-1013
                                    0x05/NT/XA60\ANON010/S-1-5-21-3142409717-2937184998-2425403696-1015
                                    0x05/NT/XA60\ANON012/S-1-5-21-3142409717-2937184998-2425403696-1017
                                    0x05/NT/XA60\ANON014/S-1-5-21-3142409717-2937184998-2425403696-1019
                            ICA\Shadowing\Users who cannot shadow other users:
                                    0x05/NT/XA60\ANON001/S-1-5-21-3142409717-2937184998-2425403696-1006
                                    0x05/NT/XA60\ANON003/S-1-5-21-3142409717-2937184998-2425403696-1008
                                    0x05/NT/XA60\ANON005/S-1-5-21-3142409717-2937184998-2425403696-1010
                                    0x05/NT/XA60\ANON007/S-1-5-21-3142409717-2937184998-2425403696-1012
                                    0x05/NT/XA60\ANON009/S-1-5-21-3142409717-2937184998-2425403696-1014
                                    0x05/NT/XA60\ANON011/S-1-5-21-3142409717-2937184998-2425403696-1016
                                    0x05/NT/XA60\ANON013/S-1-5-21-3142409717-2937184998-2425403696-1018
                            ICA\USB devices\Client USB device redirection rules - Values:
                                    DENY:  class=09 # Hub devices
                                    DENY:  class=03 subclass=01 # HID Boot device (keyboards and mice)
                                    DENY:  class=0b # Smartcard
                                    DENY:  class=e0 # Wireless Controllers
                                    DENY:  class=02 # Communications and CDC Control
                                    DENY:  class=0a # CDC Data
                                    ALLOW: # Ultimate fallback: allow everything else
                                    ALLOW: # Otherwise allow everything else 

    How to use this script?

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

    .\XA6_Inventory_V2.ps1 | out-file .\XA6Farm.doc and press Enter.

    Open XA6Farm.doc in either WordPad or Microsoft Word.

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

    ,

    About Carl Webster

    Webster is a Sr. Solutions Architect for Choice Solutions, LLC and specializes in Citrix, Active Directory and Technical Documentation. Webster has been working with Citrix products for many years starting with Multi-User OS/2 in 1990.

    View all posts by Carl Webster

    to “XenApp 6.0 Documentation Script has been Updated 21-JAN-2013”

    1. rob Says:

      Get script.

      I have one problem – I cannot get any policiy information, no matter what I do.

      I have followed the details to the letter ( except I force all PS to run unrestricted ).

      When I list the commands available even after loading the module, I do not see anything for get-xapolicy*

      Any advice would be gratefully received.

      Reply

      • Carl Webster Says:

        It is get-ctxgrouppolicy*

        What happens when you do:

        import-module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Citrix.GroupPolicy.Commands\Citrix.GroupPolicy.Commands.psm1 -verbose

        This is what I get:

        PS C:\Users\webster> import-module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Citrix.GroupPolicy.Commands\Citrix.GroupPolicy.Commands.psm1 -verbose
        VERBOSE: Loading module from path
        ‘C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Citrix.GroupPolicy.Commands\Citrix.GroupPolicy.Commands.psm1’.
        Loading Citrix.Common.GroupPolicy…
        VERBOSE: Importing function ‘Add-CtxGroupPolicyFilter’.
        VERBOSE: Importing function ‘Export-CtxGroupPolicy’.
        VERBOSE: Importing function ‘Get-CtxGroupPolicy’.
        VERBOSE: Importing function ‘Get-CtxGroupPolicyConfiguration’.
        VERBOSE: Importing function ‘Get-CtxGroupPolicyFilter’.
        VERBOSE: Importing function ‘Import-CtxGroupPolicy’.
        VERBOSE: Importing function ‘New-CtxGroupPolicy’.
        VERBOSE: Importing function ‘Remove-CtxGroupPolicy’.
        VERBOSE: Importing function ‘Remove-CtxGroupPolicyFilter’.
        VERBOSE: Importing function ‘Set-CtxGroupPolicy’.
        VERBOSE: Importing function ‘Set-CtxGroupPolicyConfiguration’.
        VERBOSE: Importing function ‘Set-CtxGroupPolicyFilter’.
        PS C:\Users\webster>

        Then do:

        PS C:\Users\webster> get-command *ctxgrouppolicy*

        CommandType Name ModuleName
        ———– —- ———-
        Function Add-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands
        Function Export-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function Get-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function Get-CtxGroupPolicyConfiguration Citrix.GroupPolicy.Commands
        Function Get-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands
        Function Import-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function New-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function Remove-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function Remove-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands
        Function Set-CtxGroupPolicy Citrix.GroupPolicy.Commands
        Function Set-CtxGroupPolicyConfiguration Citrix.GroupPolicy.Commands
        Function Set-CtxGroupPolicyFilter Citrix.GroupPolicy.Commands

        PS C:\Users\webster>

        Reply

    2. chaosNL Says:

      Great Script Carl,

      Will give it a try tommorrow, thanksss

      Reply

    Leave a Reply