Requirements
- Use a server with a GUI (I have had terrible luck with server core).
- In Server Manager, install the “Print Server” role under Print and Document Service.
Copy Current Printers
- On the new print server, open Print Management
- Right-click Print Servers -> Add/Remove Servers…
- Type the current print server in the “Add servers:” box -> Click the button “Add to list”
- If selectable, click the “Add the Local Server” button
- Hit the “OK” button
- Expand Print Servers -> Right-click the current server and select -> Export printers to a file…
- Hit the “Next >” button -> “Browse…” and save the file -> “Next” button -> “Finish” button
- The printers will be copied and exported to a file
- Right-click the new server and select -> Import printers from a file…
- Browse to the file that was exported and open it -> Hit the “Next >” button -> all the printers will list, and hit the “Next >” button twice -> “Finish” button
PowerShell Script
Save the script below as a PowerShell (.ps1); remember to change the name of the servers so it matches your current and new print server.
Store the script in a location that all devices can hit. I prefer the NETLOGON folder on a DC. \\domainName\netlogon
########################################################
# #
# #
# The First two lines are all that needs to be changed #
# Printers must be named the same on both servers #
# To work correctly #
# #
# #
########################################################
$oldPrintServer = "CTB-CORE2" # Old Print Server
$newPrintServer = "CTB-print-01" # New Print Server
$connectOldServer = (Test-NetConnection -ComputerName $oldPrintServer).PingSucceeded
$connectNewServer = (Test-NetConnection -ComputerName $newPrintServer).PingSucceeded
if(($connectOldServer -eq $true) -and ($connectNewServer -eq $true))
{
$currentComputerPrinterList = Get-WmiObject win32_printer | Select-Object Name #| Where-Object {$_.Name[0] -eq $oldPrintServer} # Gets list of printers on workstation that is being shared
$printerList =@()
foreach ($currentComputerPrinterLt in $currentComputerPrinterList)
{
$currentComputerPrinterLt = $currentComputerPrinterLt.Name
if($currentComputerPrinterLt[0] -eq '\')
{
if($connectOldServer -eq $currentComputerPrinterLt.substring(2, $oldPrintServer.Length))
{
$printerList += $currentComputerPrinterLt
}
}
}
$serverprinterList = Get-Printer -ComputerName $newPrintServer | Select-Object Name # Gets printers that are on the new server
$defaultPrinter = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true" # Gets the default printer
foreach ($printer in $printerList)
{
$printNameShort = ""
for($i = $oldPrintServer.Length + 3; $i -lt $printer.Length; $i++) # We are capturing just the printer name
{
$printNameShort += $printer[$i]
}
foreach($serverPrinter in $serverprinterList)
{
if($serverPrinter.Name -contains $printNameShort) # if the printer that we have matches the new server, remove the old one and add the new one
{
$setDefault = $false
if($defaultPrinter.Name -eq "\\$oldPrintServer\$printNameShort") # If the current printer being removed is the default printer
{
$setDefault = $true
}
Remove-Printer -Name "\\$oldPrintServer\$printNameShort" # Remove old
add-printer -connectionname "\\$newPrintServer\$printNameShort" # Add New printer as default as long as the $setDefault flag is set true
if($setDefault -eq $true) # Set the new one as the default only if
{
(New-Object -ComObject WScript.Network).SetDefaultPrinter("\\$newPrintServer\$printNameShort")
}
break
}
}
}
}
Group Policy
- Open Group Policy Management as Administrator
- Expand Group Policy Management and find the OU you want to deploy the new policy. (It is best practice to have a test OU or one with minimal users as you don’t want to affect your whole organization immediately if an issue arises).
- The selected OU needs to have user objects in it; computer objects will not be affected.
- Right-click the OU and select “Create a GPO in this domain, and Link it here…” -> Name your new policy and click the “OK” button.
- Right-click the newly created policy and select “Edit”
- Navigate to User Configuration -> Policies -> Windows Settings -> Scripts (Logon/Logoff)
- Double-click “Logon”
- In the Logon Properties popup window, select the tab “PowerShell Scripts” -> click the “Add…” button
- In the Add a Script popup window, select “Browse…”
- Find and select the script that was saved in the section PowerShell Script -> Hit the “Open” button
- Keep hitting the “OK” buttons to close the windows.
- Wait for replication and then log off and back on; you should now have the printers on the new server.