Below is a script I wrote a few months ago, it is especially useful if you are moving or changing the name of your printer server. The script looks at the current user’s installed network printers which are retrieved for example as.
If the name of the server matches the variable “from_sv” (line 14) in the script, the printer is removed from the user and a new printer of the same name is added using the “to_sv” variable (line 15) for example if the “to_sv” variable was set to “\\newprintserver;
The script does not create a queue on the new print server it just removes any reference to the old print server and as long as a queue exists on the new server it adds the printer back on for the user pointing at the new server.
To move all your printer queues, drivers and ports from one server to another take a look at Microsoft’s free tool Print Migrate
This script works great if called from a login script! And works fine on Citrix
Sometimes doing a big bang migration from an old print server to a new one is not the best idea, if you would prefer a more granular approach based on the printer model or queue name look at this script of mine. Or I have another script that could be used to just audit what printers users have as part of a planning process.
Dim from_sv, to_sv, PrinterPath, PrinterName, DefaultPrinterName, DefaultPrinter Dim DefaultPrinterServer, SetDefault, key Dim spoint, Loop_Counter Dim WshNet, WshShell Dim WS_Printers DefaultPrinterName = "" spoint = 0 SetDefault = 0 set WshShell = CreateObject("WScript.shell") from_sv = "\\printserver1" 'This should be the name of the old server. to_sv = "\\newprintserver" 'This should be the name of your new server. ' Make sure there are printers installed On Error Resume Next key = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device" DefaultPrinter = LCase(WshShell.RegRead (key)) If Err.Number <> 0 Then DefaultPrinterName = "" else 'If the registry read was successful then parse out the printer name so we can ' compare it with each printer later and reset the correct default printer ' if one of them matches this one read from the registry. spoint = instr(3,DefaultPrinter,"\")+1 DefaultPrinterServer = left(DefaultPrinter,spoint-2) if DefaultPrinterServer = from_sv then DefaultPrinterName = mid(DefaultPrinter,spoint,len(DefaultPrinter)-spoint+1) end if end if Set WshNet = CreateObject("WScript.Network") Set WS_Printers = WshNet.EnumPrinterConnections For Loop_Counter = 0 To WS_Printers.Count - 1 Step 2 PrinterPath = lcase(WS_Printers(Loop_Counter + 1)) if LEFT(PrinterPath,len(from_sv)) = from_sv then spoint = instr(3,PrinterPath,"\")+1 PrinterName = mid(PrinterPath,spoint,len(PrinterPath)-spoint+1) WshNet.RemovePrinterConnection from_sv+"\"+PrinterName WshNet.AddWindowsPrinterConnection to_sv+"\"+PrinterName if DefaultPrinterName = PrinterName then WshNet.SetDefaultPrinter to_sv+"\"+PrinterName end if end if Next Set WS_Printers = Nothing Set WshNet = Nothing Set WshShell = Nothing