Windows 7 / Getting Started

Migrating a Printer

The Print Management console is not just for managing printers on multiple print servers. It's also useful for moving printers between print servers. Printers can be migrated between all the types of print server supported by the Print Management console: Windows 2000, XP, 2003,Vista, and 2008.

Moving a printer between print servers used to be accomplished via the downloaded Print Migrator tool. It allowed printer details to be exported to a cabinet file that contained all details, shares, and drivers for the printer, and then it was imported onto the target print server. This process is essentially the same but instead of needing to download and use a separate tool, the functionality is part of the Print Management console.

To start the migration process, right-click the print server from which you want to migrate a printer and select Export Printers to a File from the context menu. The Print Migration Wizard launches with all printers selected. A summary of the actions to be performed is displayed and clicking Next requests a location and file to where the export is saved.

The dialog shows the progress of the export. Upon completion, the status of the export is displayed with information about any errors encountered. If any errors are listed, click the Open Event Viewer button. This is where the Print Migration process logs problems and details. The Event log is opened with a custom filter enabled to list only events generated by the PrintBRM process. If all went well with the migration, you should see four information logs that show that the printer object, the printer queues, the printer driver, and the printer forms were all exported.

The export can also be performed from the command line. However, the command used, printbrm, is not in a folder that is part of the default search path, so the command can only be executed by first passing the full path of the command or changing the current folder to that containing the executable, as in the following code:

E:\PrintDrives\Exports>cd /d %windir%\system32\spool\tools

The /d is added to the change directory (cd) command to change the drive just in case you are not currently on the boot volume. You then run printbrm by passing the source server, the backup switch (-b), and the file to save the configuration of the print server to.

C:\Windows\System32\spool\tools>printbrm -s \\savtstdc02 -b -f
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport
Operation mode: backup
Target server: \\savtstdc02
Target file path:
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport.
Queue publish mode: none
Overwrite Mode: keep existing settings

LISTING PRINT QUEUES
HP Officejet Pro L7680 All-in-one Lab A
LISTING PRINTER DRIVERS
HP Officejet Pro L7600 Series, Windows NT x86, PCL hpz3l4v6
LISTING PRINT PROCESSORS
hpzpp4v2 Windows NT x86 hpzpp4v2.dll
LISTING PRINTER PORTS
192.168.1.20, TCP

Saving Print Queues...
Saved print queue HP Officejet Pro L7680 All-in-one Lab A
Saving Print Processors...
Saved print processor hpzpp4v2, Windows NT x86, hpzpp4v2.dll
Saving Printer Drivers...
Saved printer driver HP Officejet Pro L7600 Series, Windows NT
x86, 3
Saving Printer Ports...
Saved printer port 192.168.1.20, TCP
************ 100% ************

This is exactly the same output as the graphical interface. The Print Management console just acts as a graphical overlay to the printbrm functionality. Notice that both methods export only the printers that have been added to the print server and not the built-in XPS-based printer.

After the export file is created, it can be imported onto the target print server. This can be run remotely. You have more options when importing than exporting. To initiate the import process, select Import Printers from a File from the context menu of the target print server. You are prompted to select the export file. Click Next to continue the import process. A summary of the file content is displayed, listing the print queues, drivers, ports, and processors that will be imported into the target print server.

You have some additional options when importing the printers. By default, if a printer being imported already exists on the target server, the printer is not imported, and the existing printer is kept. You can select to overwrite existing printers to replace any duplicate printers on the target server.

You also have options around listing printers in the AD (covered earlier), including options to list the printer in the directory if it was listed in the directory on the source print server, to list all the printers, or to not list any of the printers.

An option to convert LPR ports to standard port monitors is available. If you are importing LPR printers, this option is advantageous. Standard port monitors give a better performance than LPRs.

As with the export, the final dialog displays the completion status with a summary of any errors encountered. A link to open the event viewer with a filter to just the printbrm-generated event logs is available.

To import from the command line, use the printbrm command. Instead of the -b switch, use the -r switch. The rest of the syntax is the same. However, you do have additional switches that can be used to match the options available in the graphical interface import options. You can configure duplicate printer handling, list the printer in the AD, and convert LPR ports to standard ports. The options are as follows:

  • -o force: This option replaces any existing objects. If the printer already exists on the target server, it is overwritten.
  • -p add|orig: This option controls the publishing of the printers to the AD. Using the add option adds any imported printer to the ADpublished printers. The orig switch publishes only in the AD if the source print server had the printer published in the AD.
  • -lpr2tcp: This option converts the LPR ports to standard TCP/IP printer ports.

If you don't overwrite duplicate printers and there is a clash on execution from the command line, the following text is displayed:

Skipped print queue HP Officejet Pro L7680 All-in-one Lab A
because a queue with the same name (or same share name)
already exists

Here is an example import of the export file you created earlier. Notice the -o force parameter, which sets the overwrite mode to force new settings.

C:\Windows\System32\spool\tools>printbrm -s \\savtstdc01 -r -o force -f
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport
Operation mode: restore

Target server: \\savtstdc01
Target file path:
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport.
Queue publish mode: none
Overwrite Mode: force new settings

LISTING PRINT QUEUES
HP Officejet Pro L7680 All-in-one Lab A
LISTING PRINTER DRIVERS
HP Officejet Pro L7600 Series, Windows NT x86, None
LISTING PRINTER PORTS
192.168.1.20, TCP
LISTING PRINT PROCESSORS
hpzpp4v2 Windows NT x86 hpzpp4v2.dll

Restoring Printer Drivers...
Restored printer driver HP Officejet Pro L7600 Series, Windows
NT x86, 3
Restoring Printer Ports...
Restored printer port 192.168.1.20, TCP
Restoring Print Processors...
Restored print processor Windows NT x86, hpzpp4v2.dll,
hpzpp4v2
Restoring Print Queues...
Restored print queue HP Officejet Pro L7680 All-in-one Lab A
************ 100% ************

Successfully finished operation.

One final use of the printbrm command is to query the printer information of a server and an export file. This is useful if you have a printerExport file but are unsure of its content. The content is displayed with the -q switch. If you want to see information about a server instead of a printer export file, use the -s switch with the server name instead of the -f filename switch.

C:\Windows\System32\spool\tools>printbrm -q -f
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport
Operation mode: query
Target server: local machine
Target file path:
E:\PrintDrives\Exports\savtstdc02exportcmd.printerExport.
Queue publish mode: none
Overwrite Mode: keep existing settings

LISTING PRINT QUEUES
HP Officejet Pro L7680 All-in-one Lab A
LISTING PRINTER DRIVERS
HP Officejet Pro L7600 Series, Windows NT x86, None
LISTING PRINTER PORTS
192.168.1.20, TCP
LISTING PRINT PROCESSORS
hpzpp4v2 Windows NT x86 hpzpp4v2.dll

Displaying print hierarchy.
HP Officejet Pro L7680 All-in-one Lab A
	HP Officejet Pro L7600 Series (Windows NT x86) #1
	192.168.1.20 #1
Unassociated:

Notice in this process that the printer is not removed from the source print server. This is to aid a smooth migration because you still need to move clients from pointing to the old print server to the new print server. If you just removed the print queue from the old server before the clients were moved, you would have an unhappy client base. After all the users are migrated to the new printer server, remove the printers from the old print server.

In terms of updating the clients to use the new print server, ideally you are using group policy to deploy the printers to the user base and so the process is fairly simple. Deploy the printer on the new print server to the same group used on the old print server. Delete the deployment of the printer via the old print server. Clients then get the new printer at the same time the old one is removed in a seamless fashion.

If group policy is not an option, use a script that swaps a printer for another via a logon script. Here is a basic script that replaces one printer mapping for another:

Option Explicit
Dim objWMIService, objPrinter, colItems, strComputer
Dom objWshShell, strDefaultState

strComputer ="."

Set objWshShell = WScript.CreateObject("WScript.Shell")

Set objWMIService = GetObject("winmgmts:\\" & strComputer & _

	"\root\CIMV2")

Set colItems = objWMIService.ExecQuery _
	("SELECT * FROM Win32_Printer")

' On Error Resume Next
For Each objPrinter In colItems
If UCase(objPrinter.DeviceID) =
UCase("\\savdalprinterOld\printer1") Then
    Wscript.Echo "Found match " & objPrinter.DeviceID & _
	", replacing"
    ' Add new printer. Need the ,1,true to wait
    'for shell to complete before continue
    objWshShell.Run "rundll32 printui.dll,PrintUIEntry /in /Gw
   /q /n \\savdaldc01\printerNew",1, true

	' Remove the old
	objWshShell.Run "rundll32 printui.dll,PrintUIEntry /dn /q
    n \\savdalprinterOld\printer1",1, true

    If objPrinter.Default Then ' if it's the default set as
  default
	objWshShell.Run "rundll32 printui.dll,PrintUIEntry /y /n
  \\savdaldc01\printerNew",1, true
    End If
 End If
Next

WScript.Quit

If you use this, you'll need to replace the old and new printer in three places in the script. Reading from the script gives you ideas on how to manage printers via scripting interfaces. For example, you enumerate all the printers on the local computers by querying WMI and selecting all entries from the Win32_Printer class.

To remove and add printers, use the printui dynamic link library (dll). You also use it to set it as the default printer (if the printer you are replacing was the default).

[Previous] [Contents] [Next]