i'm setting up our new citrix 6.5 enviroment (6.5 w/ rollup pack 1). of course, we need printer policies for the users. after our internal discussions, we're setting up 1 policy per printer (for each printer that has a matching security group in AD, 599 policies to be created*), and 1 policy per remote subnet (main office locations exempted, 188 total policies to create), so users at remote subnets will get their 'local' printers no matter what site they are at each day, and we can also guarantee certain printers are always available to certain users (check printers for AP, private printers for HR, etc). This is far too many policies to create by hand, so scripting via powershell will reduce the time required & risk of input errors.
I exported a list of print queue's from one of the load balanced print servers, used dsquery to confirm which printers had matching security groups, and then generated the powershell for each printer via an excel spreadsheet (yes, it could be done via a loop with an imported csv, but i wanted the individual lines available for documentation in the project folder).
setting up the policies for the individual printers filtered by security group is easy via citrix's powershell extension, these lines create the policy, apply a security group filter, and set the policies properties.
removing the entire policy is also easy:
if you are creating/modifying a lot of policies, executing
before you interact with the policies and running
afterwards significantly improves the speed of execution & eliminates a nasty memory leak.
to setup the subnet based ones, a little bit of shenanigans are required, since a particular subnet (and thus a policy) might need more than 1 printer.
again, create the policy, set a subnet filter, but then store the current value of the session printers to a variable, append the new printer to the variable, and then set the value which will overwrite the current policy value with the updated value of the variable.
now if i could just figure out how to adjust policy priority via powershell instead of the GUI.
*we needed to apply GPCSExt170W2K8R2X64001 after creating this many policies, otherwise user sessions would time out during login, issue w/ Citrix CSE using excessive CPU when processing policies.
I exported a list of print queue's from one of the load balanced print servers, used dsquery to confirm which printers had matching security groups, and then generated the powershell for each printer via an excel spreadsheet (yes, it could be done via a loop with an imported csv, but i wanted the individual lines available for documentation in the project folder).
setting up the policies for the individual printers filtered by security group is easy via citrix's powershell extension, these lines create the policy, apply a security group filter, and set the policies properties.
Code:
new-item LocalFarmGPO:\User\POLICYNAME
New-Item LocalFarmGpo:\User\POLICYNAME\Filters\User\SECURITYGROUP@DOMAIN
set-itemproperty LocalFarmGPO:\User\POLICYNAME\Settings\ICA\Printing\SessionPrinters -name values "\\PRINTSERVER\PRINTQUEUE"
removing the entire policy is also easy:
Code:
remove-item LocalFarmGPO:\User\POLICYNAME -recurse -Confirm:$false
if you are creating/modifying a lot of policies, executing
Code:
(Get-PSDrive LocalFarmGpo).AutoWriteBack = $false
Code:
(Get-PSDrive LocalFarmGpo).Save()
(Get-PSDrive LocalFarmGpo).AutoWriteBack = $true
to setup the subnet based ones, a little bit of shenanigans are required, since a particular subnet (and thus a policy) might need more than 1 printer.
again, create the policy, set a subnet filter, but then store the current value of the session printers to a variable, append the new printer to the variable, and then set the value which will overwrite the current policy value with the updated value of the variable.
Code:
New-Item LocalFarmGPO:\User\POLICYNAME
New-Item LocalFarmGPO:\User\POLICYNAME\Filters\ClientIP\FILTERNAME -Value NETWORK/CIDR
$CurrentPolicyPrinters = Get-ItemProperty LocalFarmGPO:\User\POLICYNAME\Settings\ICA\Printing\SessionPrinters
$CurrentPolicyPrinters.Values += "\\PRINTSERVER\PRINTQUEUE"
Set-ItemProperty LocalFarmGPO:\User\POLICYNAME\Settings\ICA\Printing\SessionPrinters -name values $CurrentPolicyPrinters.Values
now if i could just figure out how to adjust policy priority via powershell instead of the GUI.
*we needed to apply GPCSExt170W2K8R2X64001 after creating this many policies, otherwise user sessions would time out during login, issue w/ Citrix CSE using excessive CPU when processing policies.
user'