How to keep your printer drivers in sync at your Xenapp 6.x farm

Although there are a number of methods and tools to maintain print-driver replication amongst Xenapp servers, the main objective is to keep your drivers in sync with your print-server. Setting up a Xenapp farm means that users don’t have the right to add print-drivers. And so even when the most piddling DLL deviates from your print server your users are presented with malignant looking windows demanding all sorts of admin stuff. Can your hear the phone ringing at the service desk…?

Even though best practice tells us to use Citrix Universal Print Server, using proprietary drivers is hardly avoidable. Now Citrix offers two methods: Using Powershell and using the Print Management Administrative Tool. The first is explained extensively, but the latter hardly. While I think this is the perfect tool to make syncing of printer-drivers between printserver and Xenapp server easy and fool proof.

Of course we’re not gonna use the GUI but the CLI tool underneath: the printbrm.exe This little bugger is gonna sync our print-drivers. Besides a Windows 2008 R2 print server, a prerequisite is the installation of RSA tools for print management. Using Powershell, the installation is done fairly easy.

Import-Module Servermanager Add-WindowsFeature RSAT-Print-Services

A drawback of using the GUI is that it won’t let you export drivers only. You’ll end up with an export file containing printers, ports & drivers. Let’s have a look at the script which will export just those drivers.

****Create Export PrintServer file****
c:\windows\system32\spool\tools\printbrm -B -F C:\PrnDrv_Export\PrnDrvEx.printerexport
rem ****Expand Export PrintServer objects****
c:\windows\system32\spool\tools\printbrm -R -D c:\PrnDrv_Export -f c:\PrnDrv_export\PrnDrvEx.printerexport
rem ****Remove Printers & Ports****
xcopy C:\PrnDrv_Export\import\*.xml C:\PrnDrv_Export /C /Y
rem ****Copy import file to Sources****
c:\windows\system32\spool\tools\printbrm -B -D C:\PrnDrv_Export -F C:\PrnDrv_Export\PrnDrvIm.printerexport
rem ****Clean up****
del C:\PrnDrv_Export\Printers\*.xml /F /Q
del c:\PrnDrv_Export\*.xml /F /Q
del c:\PrnDrv_Export\PrnDrvEx.printerexport /F /Q
del c:\PrnDrv_Export\Drivers\*.* /S /F /Q
del c:\PrnDrv_Export\LMONS\*.* /S /F /Q
del c:\PrnDrv_Export\Printers\*.* /S /F /Q
del c:\PrnDrv_Export\PRTPROCS\*.* /S /F /Q

Basically what it does is:

  • Export printers, ports & drivers to an export file
  • Expand the export file
  • Replaces the printer & port XML files with empty ones
  • Compress the content back to an export file without printer-objects and port-objects
  • Clean up

As you can see, the script requires a folder structure to be present on the print server. For your convenience I added a zip-file containing this folder structure, including the necessary XML files. Unzip this in the root of the C:\ drive of your printserver.

PrnDrv_Export

After copying the export file to a central place on your network it’s an easy job to deploy it to your Xenapp servers. Your Xenapp servers need to have the RSAT Print Management feature installed as well.

c:\windows\system32\spool\tools\printbrm -R -F %drive%\PrnDrvIm.printerexport -O Force

Using the printbrm tool each time you make a change on your printerserver will give you the assurance that you’ll have exactly the same set of print-drivers on your Xenapp servers present. Using tools like RES Automation Manager or MS System Center makes it even easier to import and export the printerexport files from the printserver to your Xenapp server.

10 comments

  1. Hi Misja,

    For XenApp 6.5, you can use Farm Nanny to replicate your printer drivers as well.

    • Hey Steve,

      Looks like a functional tool. But this one as well doesn’t sync your print drivers with the print server. Just only amongst your Xenapp servers.

  2. Jered Gaspard says:

    This is a fantastic post. I had started to do this the hard way – install print services, export from print server, import to XA server via print management, then delete the printers and ports and just leaving the drivers in place. This is a much cleaner and preferred solution. Thanks Misja.

  3. Mike Jones says:

    I have ran this twice. It seems to do everything it is supposed too, but I do not end up with a PrnDrvIm.printerexport file.

    If I watch the folder while its running, I see when the PrnDrvEx.printerexport is created, but once the script goes through all the deletes it removes that and never creates the PrnDrvIm.printerexport file.

    Any ideas?

    • Mike Jones says:

      NVM I think I figured it out. The createdriverfile.bat has a path coded into it where it is supposed to copy the printexport file. Had to change that to a path that exists in my environment.

      • Mike Jones says:

        Nope that wasn’t it either. Seems the PrnDrvIm.printerexport never gets created. I am stepping through each line in the .bat file manually and will report back with what happens.

        • Hi Mike,

          I’ve attached a new zip file to this post. The copy of PrnDrvIm.printerexport file to a secondary resource has been removed and in the removal section of the script I specified the PrnDrvEx.printerexport file to be removed and not *.printerexport.

          If you want to add a Xcopy action, feel free to do so.

          Cheers,
          Misja

          • Mike Jones says:

            So those were parts of the problem. It ended up being that when the prndrvim.printerexport file was being created the prndrvex.printerexport file was still in the folder, since the delete’s happen after the new file is built.

            So I think it was trying to compile everything in the folder, including the prndrvex.printerexport file and failing. It didn’t work until I manually deleted that file, and then ran the printbrm command again. Then everything worked fine.

            So you might want to have it delete the prndrvex file prior to the compile of prndrvim.

            Either way though this is greatly helpful, so thank you!

  4. Hey Misja,

    just what I needed! I was thinking back about our project where we used this and you made a blog article about it.

    Cheers mate! Hope you’re doing well!

  5. I added this text first to rename the previous export file since your script did not overwrite that:

    rem ***** Rename printerdriver exportfile

    Set CURRDATE=%TEMP%\CURRDATE.TMP
    Set CURRTIME=%TEMP%\CURRTIME.TMP

    DATE /T > %CURRDATE%
    TIME /T > %CURRTIME%

    Set PARSEARG=”eol=; tokens=1,2,3,4* delims=/, ”
    For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYYMMDD=%%l%%k%%j

    Set PARSEARG=”eol=; tokens=1,2,3* delims=:, ”
    For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMM=%%i%%j%%k

    pushd C:\PrnDrv_Export
    RENAME PrnDrvIm.printerexport PrnDrvIm_%YYYYMMDD%%HHMM%.printerexport
    popd

Leave a Reply to Mike Jones Cancel 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.