Set a redirected printer as default on remote desktop session

Our printers on the remote desktop server are deployed using the print server and one of the issues faced was allowing users to set their redirected printers as default when working from remote locations / wanting to use their local printers. We added a script to each user profile to workaround the default setup

Here's the script:

$printer='Microsoft XPS Document Writer'

$records = quser EZUser

$sessid = $records.split(' ')

$selprinter = $printer [plus] ' (redirected ' $sessid[54] ')'

$p = Get-WMIObject -query "Select * From Win32_Printer Where Name = '$selprinter'"

$p.SetDefaultPrinter()

Explanation:

Define the redirected printer you would like to set as default

Run quser on the username (replace EZUser above with the username) and save it in a variable

Convert string to Array

Array 54 gives you the session id of the user

define the printer name

Run a WMI query for the printer

set the printer to default

I hope this helps. If you can come up with a better script, please email us.