# Solved: Print Server Transfer



## LinuxHacker (Jan 1, 1970)

I have copied all of my network printers to a new print server using Microsoft's Printer Migration Tool. Does anyone know a script or another way to delete all of the end user's network printers (not local printers) from the old server and install the new network printers on the new print server?

I'm too lazy to walk to each machine.


----------



## LinuxHacker (Jan 1, 1970)

I figured it out.

this script will remove old network printers, add new network printers and set default printer to a network printer if a local printer does not exist.





On Error Resume Next 

Dim OldPrint, UNCpath1, UNCpath2, UNCpath3, UNCpath4, NewPrint, strComputer, objWMIService, LocalPrinter 

UNCpath1 = "\\Fileserver\BrotherW6th" 
UNCpath2 = "\\Fileserver\CanoniP6" 
UNCpath3 = "\\Fileserver\HPLaser2015" 
UNCpath4 = "\\Fileserver\OKIC5300" 

Set OldPrint = WScript.CreateObject("WScript.Network") 
OldPrint.RemovePrinterConnection UNCpath1, true, true 
OldPrint.RemovePrinterConnection UNCpath2, true, true 
OldPrint.RemovePrinterConnection UNCpath3, true, true 
OldPrint.RemovePrinterConnection UNCpath4, true, true 

Set NewPrint = CreateObject("Wscript.Network") 
NewPrint.AddWindowsPrinterConnection "\\Fileserver2\BrotherW6th" 
NewPrint.AddWindowsPrinterConnection "\\Fileserver2\CanoniP6" 
NewPrint.AddWindowsPrinterConnection "\\Fileserver2\HPLaser2015" 
NewPrint.AddWindowsPrinterConnection "\\Fileserver2\OKIC5300" 

strComputer = "." 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set LocalPrinter = objWMIService.ExecQuery("Select * From Win32_Printer Where Local = TRUE") 

If LocalPrinter.Count = 0 Then 
NewPrint.SetDefaultPrinter "\\Fileserver2\HPLaser2015" 
End IF

WScript.Quit


----------

