Re-map all printers from one server to another

Script to migrate users from one server to another

Running the below will migrate all printer connections from “OLD-SERVER” to “NEW-SERVER” While keeping the original name of the printer.

strOldServer = "OLD-SERVER"
strNewServer = "NEW-SERVER"


strComputer = "."
Set WSHNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer")

strOldServer = prepServer(strOldServer)
strNewServer = prepServer(strNewServer)

For Each objPrinter in colInstalledPrinters
strName = objPrinter.Name
iPrinterLocation = InStr(UCase(objPrinter.Name),UCase(strOldServer))
If iPrinterLocation > 0 then
strPrinter = strNewServer & Right(strName, Len(strName) - Len(strOldServer))
objPrinter.Delete_
WSHNetwork.AddWindowsPrinterConnection strPrinter
If objPrinter.Default = True Then
WSHNetwork.SetDefaultPrinter strPrinter
End If
End If
Next


Function prepServer(strServer)
If Left(strServer, 2) <> "\\" then
strServer = "\\" & strServer
End If
If Right(strServer, 1) <> "\" then
strServer = strServer & "\"
End If
prepServer = strServer
End Function