Printer Migration Old to New Server

Migrate your print server quickly, and users won't even notice.

Table of Contents

Requirements

  1. Use a server with a GUI (I have had terrible luck with server core).
  2. In Server Manager, install the “Print Server” role under Print and Document Service.

Copy Current Printers

  1. On the new print server, open Print Management
  2. Right-click Print Servers -> Add/Remove Servers…
  3. Type the current print server in the “Add servers:” box -> Click the button “Add to list”
  4. If selectable, click the “Add the Local Server” button
  5. Hit the “OK” button
  6. Expand Print Servers ->  Right-click the current server and select -> Export printers to a file…
    1. Hit the “Next >” button  -> “Browse…” and save the file -> “Next” button -> “Finish” button
    2. The printers will be copied and exported to a file
  7. Right-click the new server and select -> Import printers from a file…
    1. 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

  1. Open Group Policy Management as Administrator
  2. 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).
    1. The selected OU needs to have user objects in it; computer objects will not be affected.
  3.  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.
  4. Right-click the newly created policy and select “Edit”
  5. Navigate to User Configuration -> Policies -> Windows Settings -> Scripts (Logon/Logoff)
    1. Double-click “Logon”
  6.  In the Logon Properties popup window, select the tab “PowerShell Scripts” -> click the “Add…” button
  7. In the Add a Script popup window, select “Browse…”
  8. Find and select the script that was saved in the section PowerShell Script -> Hit the “Open” button
  9. Keep hitting the “OK” buttons to close the windows.
  10. Wait for replication and then log off and back on; you should now have the printers on the new server.

Tags

Contact Us