On Windows PowerShell and other admin-related topics

Adding printer drivers from a print server using Windows PowerShell

Managing printer drivers in a Remote Desktop Services (formerly Terminal Services) environment can be a challenge for administrators. There are many ways to ease this challenge, including third party solutions such as ThinPrint and UniPrint. When “thick” drivers are used on the RDS servers, all printer drivers must be installed locally on every server. Citrix XenApp has a printer driver replication feature which makes it possible to distribute printer drivers from a source server to one or more destination servers in a farm.

There might be situations where none of the mentioned solutions can be used for various reason, i.e. financial costs. A common way to solve this problem is to map all printer connections from a specified print server using administrative credentials during the initial setup of each RDS server. This solves the problem, but it can be time consuming as all printers that uses the same driver is being installed. Even though the driver is already installed on the local computer, it takes some time to process each printer connection.

I recently faced this challenge, as the installation of all printer connections from a few specified print servers took 30-40 minutes using a legacy script. I then wrote an advanced function in PowerShell to make the procedure more effective. This was accomplished by installing a printer connection only for unique printer drivers.
An example: A print server has 500 shared printer objects, while there is only 10 unique printer drivers. It would make more sense to add a printer connection (in order to install the driver) to 10 printer objects rather than 500, given the time consumed by installing a printer connection.

The function is available for download from here.

Sample usage and output:




There is a switch option added to the function called Clean. If this parameter is specified the function will also remove all mapped printer connections for the current user.

The function doesn’t`t provide any log options. However, it produces PowerShell objects, so it would be easy to pipe the output to a file.
An example on how to export the output objects to a csv-file:


But what about printer drivers added to the print servers after the function is run on an RDS server? One way to solve this could be adding the PowerShell function to a script-file which is set up as a scheduled task to run i.e. once a day on every RDS server.  If the scheduled task is set up using Group Policy Preferences, it will be automatically created on every new RDS server that is added later on. Beside scheduling the task to run at specified intervals, the print server administrator may also invoke the scheduled task remotely on every RDS server whenever a new print driver is added to a print server. The details on how to do this is previously described in this blog-post.

Since the function might be run several times on the same computer, it also checks if the driver to be installed is already in place on the local computer. This means that after the first run, only printer drivers added to the print server after the first run is actually installed. This makes the script more effective, and depending on the number of shared printer objects on the specified print server, it shouldn’t`t run for many seconds.

Coming back to the before mentioned example (~600 printer objects, ~50 unique drivers) where it took 30-40 minutes to install printer drivers from a print server, when using the Add-PrinterDriver PowerShell function the execution ran for 4 minutes. After the first run, subsequent executions ran for  20 seconds.


July 3, 2011 - Posted by | Print management, Remote Desktop Services, Scripting, Terminal Services, Windows PowerShell, Windows Server 2008, Windows Server 2008 R2 | , , , ,


  1. […] wenn ich deine meinung richtig verstanden, guckmal diese link: Adding printer drivers from a print server using Windows PowerShell Wenn ich falsch verstanden, zuerst sorry, dann sag es bitte, was meinst du genau? […]

    Pingback by Druckertreiber per Powershell exportieren - MCSE Forum | September 7, 2011 | Reply

  2. Dosent work with MSCS print cluster…,

    Comment by Moeed | October 6, 2011 | Reply

  3. […] Windows PowerShell December 2, 2011 robertrieglerwien Leave a comment Go to comments… Share this:PrintEmailLike this:LikeBe the first to like this post. Categories: Developement, MS: […]

    Pingback by Adding printer drivers from a print server using Windows PowerShell « MS Tech BLOG | December 2, 2011 | Reply

  4. […] Schultze on the Replicating Print Drivers in Citrix XenApp 6.5 blog post for more details.Resource :Adding printer drivers from a print server using Windows PowerShellShareHave a comment to share?One of the big reasons that I blog is because I like people and I want […]

    Pingback by Adding Printer Drivers from Print Server using PowerShell | February 2, 2012 | Reply

  5. […] Schultze on the Replicating Print Drivers in Citrix XenApp 6.5 blog post for more details.Resource :Adding printer drivers from a print server using Windows PowerShell […]

    Pingback by - Cliff Davies | February 2, 2012 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: