I’m providing a few scripts here that simplify the migration of a print server. Of course, you can also do it with Printmig or other tools. I wanted to install my new print server from scratch, so I decided to do this via PowerShell scripting and without any third party tool.
The migration will take place in four parts:
- Step #1: Export TCP and LPR ports
- Step #2: Export printers with all settings to an XML file
- Step #3: Import TCP and LPR ports
- Step #4: Import all printers with all settings
Part #1: Export TCP and LPR Ports
Different information are needed for the later import of the two port types, so I have created two scripts that export the configurations:
Export LPR Ports to CSV
Frist script exports all LPR Printer Ports with all settings to a csv file. In the csv file there are name, protocol, port nubmer and printer host address.
https://github.com/tsukaito-code/Powershell/blob/main/Printserver/Export-PrinterPorts_LPR_to_CSV.ps1
Second script exports all TCP Printer Ports with all settings to a csv file. In the csv file there are address, port number and smtp settings.
https://github.com/tsukaito-code/Powershell/blob/main/Printserver/Export-PrinterPorts_TCP_to_CSV.ps1
Part #2: Export printer with all settings to an XML file
The next script exports all installed network printers. It creates a CSV file containing basic printer information. Additionally, it exports the configuration for each printer to an XML file, which includes the complete configuration of trays, paper sources, etc. This information allows the printers to be fully restored on the new server later.
Part #3: Importing TCP and LPR Ports
Now we can create the TCP and LPR ports on the new print server. Here again, there are two scripts because TCP ports are created differently than LPD ports.
IMPORTANT: Before creating the LPR ports, the LPD service must first be installed via Server Manager so that the LPR port type is available.
HINT: If the names or IP addresses of the ports need to be changed, please adjust them in the CSV file before running the script!
First script creates all LPR Printer Ports with all settings from a csv file.
In the csv file there are name, protocol, port nubmer and printer host address.
Second script creates all TCP Printer Ports with all settings from a csv file. In the csv file there are address, port number and smtp settings.
IMPORTANT:
Before proceeding to the next step, all necessary printer drivers must be installed on the new server. If the name or version of the printer drivers changes, they must be updated in the exported CSV file between Step #3 and #4.
After the printer drivers are installed, you can use Get-PrinterDriver to display the printer drivers. Under „Name,“ you will find the name that must be replaced in the CSV file. If the name doesn’t match, you will receive an error message when creating the printer at step 4, indicating that the driver could not be found. Once the drivers are installed and the CSV has been adjusted if necessary, the printers can be created using PowerShell (including the configuration from the XML file).
Note:
It got some trouble with label printers like Zebra. This printers require separate verification of settings, because it looks like some information are not stored in the Windows driver (like printhead configuration).
Also a short hint for printers that are OFFLINE (turned off). This devices takes approximately one minute (TCP timeout) to be created and slow down your script but no worries, the script will go ahead after that without error.
https://github.com/tsukaito-code/Powershell/blob/main/Printserver/Create-Printers_from_CSV.ps1