Print Server Migration

Recently I had to retire an end of life Windows 2008 R2 print server, as you will see from the image below the number of drivers on the server was significant compared to the number of printers deployed:

Over the years drivers had been migrated with each server upgrade as well as when a new driver was updated by the manufacturer. Moving forward there is the question of how do I migrate the printers without bringing over all of the crap that I don’t need?

A: A few lines of code and some know how:
1. On the old server open an administrative command prompt and set the current directory to the printer tools directory
cd “C:\Windows\System32\Spool\Tools
2. run¬ Printbrm -b -f Printserverconfig.printerexport in the same window, this will take some time to complete especially if you have a large number of drivers, wait for the tool to fully complete its task.

-sidenote¬ I have seen this tool not work as expected when using PowerShell to be safe when using printbrm.exe you should use it in an administrative command prompt.
3. create a child folder in the current tools directory, I named mine “Migrate”

 

 

 

4.¬ expand the printer export file you created using the following command:
printbrm.exe -r -d C:\Windows\System32\Spool\Tools\Migrate -f Printserverconfig.printerExport

5. using the newly created expanded backup we will use PowerShell to format the xml file:

$printdrivers = [xml](Get-Content C:\Windows\System32\spool\tools\Migrate\BrmDrivers.xml)            
$printdrivers.Save("C:\Windows\System32\spool\tools\Migrate\BrmDrivers.xml")


6.¬ Open the newly edited print drivers xml file in text editor, remove unneeded drivers; ensure both x64 and x86 driver versions are listed:
7.¬ Save the file in text editor and create new printer export file:
printbrm.exe -b -d C:\Windows\System32\Spool\Tools\Migrate -f newPrintserverconfig.printerExport
8. Log onto new Print Server and copy the¬ newPrintserverconfig.printerExport file into the same directory on the new server
9. Printer import requires the firewall to be running in order to add the ports through the firewall. if you have the firewall running you can skip this step.¬
In PowerShell run:¬

(gwmi win32_service -filter "Name='mpssvc'").ChangeStartMode("Manual") ;(gwmi win32_service -filter "Name='mpssvc'").startservice()

10. install the printers on the new server using Printbrm:

C:\Windows\System32\Spool\Tools\PrintBrm.exe -r -f C:\Windows\System32\Spool\Tools\NewPrintserverconfig.printerExport

11. set the print share security using PowerShell:

Grant-SmbShareAccess -name Print$ -AccountName "Authenticated Users" -AccessRight Read -force            
Revoke-SmbShareAccess -name Print$ -AccountName Everyone -Force            
CMD /C 'Icacls C:\Windows\System32\spool\drivers /grant:r "Authenticated Users":(OI)(CI)RX /remove "Everyone"'            

12. If you started the firewall previously and needed to stop and disable it again use the following:

(gwmi win32_service -filter "Name='mpssvc'").stopservice() ; (gwmi win32_service -filter "Name='mpssvc'").ChangeStartMode("Disabled")

 

Now you should notice that on your new server you have the printers you need with considerably less drivers

 

 

Below is all of the code¬ broken down for ease of use:

#On old server:            
cd ‚ÄúC:\Windows\System32\Spool\Tools‚ÄĚ            
C:\Windows\System32\spool\tools\Printbrm.exe -b -f Printserverconfig.printerexport            
mkdir Migrate            
C:\Windows\System32\spool\tools\printbrm.exe -r -d C:\Windows\System32\Spool\Tools\Migrate -f Printserverconfig.printerExport            
$printdrivers = [xml](Get-Content C:\Windows\System32\spool\tools\Migrate\BrmDrivers.xml)                        
$printdrivers.Save("C:\Windows\System32\spool\tools\Migrate\BrmDrivers.xml")            
            
#Make changes to the BrmDrivers.xml file removing the uneeded drivers before running the next line            
printbrm.exe -b -d C:\Windows\System32\Spool\Tools\Migrate -f newPrintserverconfig.printerExport            
            
#On the new server:            
(gwmi win32_service -filter "Name='mpssvc'").ChangeStartMode("Manual") ;(gwmi win32_service -filter "Name='mpssvc'").startservice()            
C:\Windows\System32\Spool\Tools\PrintBrm.exe -r -f C:\Windows\System32\Spool\Tools\NewPrintserverconfig.printerExport            
Grant-SmbShareAccess -name Print$ -AccountName "Authenticated Users" -AccessRight Read -force                        
Revoke-SmbShareAccess -name Print$ -AccountName Everyone -Force                        
CMD /C 'Icacls C:\Windows\System32\spool\drivers /grant:r "Authenticated Users":(OI)(CI)RX /remove "Everyone"'            
(gwmi win32_service -filter "Name='mpssvc'").stopservice() ; (gwmi win32_service -filter "Name='mpssvc'").ChangeStartMode("Disabled")