In a previous article I explained how you can set Citrix (domain) policies via PowerShell. In one of the comments I got a question from Tony who wanted to set Session Printers. In this article I’ll explain how this is done.

In the article I will first show a quick example and then show some more detailed setting.

The basics

Before we can set the specific Session Printers settings we need to load the correct modules, connect to the GPO and read the Citrix user policy. These steps are the same as in the – Set Citrix policies via PowerShell – article.

#Import module
Import-Module .\Citrix.GroupPolicy.Commands

#Connect PowerShell drive to Citrix domain GPO
New-PSDrive -Name CitrixGPO -PSProvider CitrixGroupPolicy -Root \ -DomainGPO "Citrix GPO"

#Read Citrix user policy
$objCitrixPolicy = Get-CtxGroupPolicyConfiguration -PolicyName "Unfiltered" -Type user -DriveName CitrixGPO

#Set session printers
$objCitrixPolicy.("SessionPrinters").State = "Enabled"
$objCitrixPolicy.("SessionPrinters").Values=@("\\DC001\Printer1,model=HP LaserJet 4, color=1, location=";"\\DC002\Printer2, model=HP LaserJet 4, location=Second floor")

#Write Citrix user policy
Set-CtxGroupPolicyConfiguration $objCitrixPolicy -DriveName CitrixGPO

#Close PowerShell Drive from Citrix domain GPO
Remove-PSDrive -Name CitrixGPO

In the example above I added two printers: Printer1 and Printer2 which are both located on the server DC001. The result is shown below.

Session Printers

In the example my GPO is called “Citrix GPO” and I’m using the “Unfiltered” Citrix policy.

 

 

SessionPrinters Values

The syntax and the possible values for the setting “SessionPrinters” are not documented in the XenApp 6.5 Powershell SDK but their quite straightforward.

 

In general there are two settings for each policy

  • State : Is the setting applied? Possible values are: NotConfigured, Enabled, UseDefault
  • Values: A one-dimensional array containing a list of session printers.




Session printer syntax

For each session printer one comma separated string is constructed with the following syntax

<URL>,model=<model>(,location=<location>)(optional settings)

Where

  • <URL> is Server + Shared Name (for example \\DC001\Printer1);
  • <model> is the model name of the printer, or friendly name of the printer driver (for example HP LaserJet 4);
  • <location> the location value of the shared printer (for example Second floor).

The URL and model are mandatory, the location is optional.

Session Printers - Settings

Example

Two session printers are added: Printer1 and Printer2, both hosted on DC001 with the same printer driver (HP LaserJet 4). Printer2 has a location: Second floor:

  • \\DC001\Printer1,model=HP LaserJet 4, location=
  • \\DC001\Printer2,model=HP LaserJet 4, location=Second floor

The following command can be issued from PowerShell

$objCitrixPolicy.("SessionPrinters").Values=@("\\DC001\Printer1,model=HP LaserJet 4, location=";"\\DC002\Printer2, model=HP LaserJet 4, location=Second floor")

 

 

Printer Settings

As you’ve probably noticed in the example the settings for Printer1 are marked as Modified. For each session printer you have the ability to override printers settings like print quality, orientation, paper size, etc. Each setting is added to the same string as the URL, model and location and separated by a comma ‘,’. If no value is provided the printer setting is not configured (default).

As mentioned before the possible values are not documented in the SDK so I’ve documented them here.

 

Basic

Printer Settings - Basic

Printer Setting Member Name Value Description
Override print quality printQuality -1 150dpi
    -2 300dpi
    -3 600dpi
    -4 1200dpi
    (numeric value) The provided value for custom horizontal
  yResolution (numeric value) The provided value for custom Vertical (only when a value is provided for printQuality)
Override orientation orientation portrait Portrait
    landscape Landscape
Override color color 1 Monochrome
    2 Color
Override duplex duplex 1 Simplex
    2 Vertical
    3 Horizontal




Advanced

Printer Settings - Advanced

Printer Setting Member Name Value Description
Override scale scale (numeric value) The provided value in percentage (for instance 100 for 100%)
Override copy count copies (numeric value) The provided value is the number of copies
  collate True / False Collation is enabled / disabled
Override TrueType option trueTypeOption 1 Bitmap
    2 Download
    3 Substitute
    4 Outline

 

Paper

Printer Settings - PaperEither paper size of form name is overridden, you can’t apply both .

Printer Setting Member Name Value Description
Override paper size paperSize 1 Letter
    2 Letter Small
    3 Tabloid
    4 Ledger
    5 Legal
    6 Statement
    7 Executive
    8 A3
    9 A4
    (etc.) The number increments as it’s shown in the dropdown box
Override form name formName (string value) The value provided in the value



Example

Just like the previous example two session printers are added but in this example the settings for Printer1 are changed. The print quality is lowered to 300dpi, the colors are set to monochrome and the paper size to A4.

  • \\DC001\Printer1,model=HP LaserJet 4, printQuality=-2, color=1, paperSize=9, location=
  • \\DC001\Printer2,model=HP LaserJet 4, location=Second floor

The following command can be issued from PowerShell

$objCitrixPolicy.("SessionPrinters").Values=@("\\DC001\Printer1,model=HP LaserJet 4, printQuality=-2, color=1, paperSize=9, location=";"\\DC002\Printer2, model=HP LaserJet 4, location=Second floor")

 

 

.

3 Comments

  1. Thank you for this post, it is a really good part of what I need to create multiple printers policy. I need also to change the priority level of the policies I will do with my Powershell ! Have you got any idea on how I can do that with Powershell ? Best regards !

  2. This is very informative, but I need a different policy setting: Printer Assignments. (It allows a filter per printer or set of printers rather than per policy. Thus we can have one policy instead of 45.)

    In some ways it is similar to Session Printers, but it has an Index, then Session Printer and Filter objects under each index, and then another index under each of those before you can actually make the setting. I can create filters, but I have been unable to create Session Printers. I either get “That isn’t a UNC” or “Could not find a PSdrive for that UNC” Any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_USEnglish