Powershell – Exporting and Importing Printer Settings using PowerShell

powershellprinter

I am looking for a solution to export settings which were made on a specific printer which uses for example a "CAB A3 300DPI" Driver and import them afterwards on a diffrent device, which is using the same driver. To do that I want to use PowerShell. I am well aware of the PrintUI.dll but this causes too many errors on my side when I try to import the settings on some printers..

I already found a solution to import the "Printing Defaults…" under the menu entry "Advanced" but none yet for the settings for "Preferences…" under the menu entry "General".

For the export and import for the "Advanced"->"Printing Defaults…" I used the following commands found here Copy printer defaults to other printers:

Export:

$somePrinterConfig = Get-PrintConfiguration -PrinterName "xxxxxx" 

Import:

Set-PrintConfiguration -PrinterName "yyyyyy" -PrinterTicketXml     $somePrinterConfig.PrintTicketXML 

Anyway like I said this is just a partial solution since I still need to export and import the printer's "General"->"Preferences…" settings for the printer.

Something mentioned earlier the PrintUI.dll which I used causes errors when importing the settings on some of the printers. For this I used the following here:

Export:

RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n "name_of_printer" /a "path_of_file_to_export.dat"

Import:

RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Sr /n "name_of_printer" /a "path_of_file_to_import.dat" 2 7 c d g u

I also should mention that I exported the settings on a Windows Server 2008 Service Pack 2 and imported them on a Windows Server 2012 r2.

Every input in highly appreciated!

Best Answer

this is late for you... but I figured out how this works last year and posted it on technet:

This is generally how to export printer configurations using powershell's built in commands and apply them to another printer (It is a powershell replacement for printui dll)

https://gallery.technet.microsoft.com/scriptcenter/Powershell-printer-config-db0465bd

Hope it helps someone here :-)

MithUK