Updating Printer Configurations
by Jethro Tierney [Profile] | Wednesday, December 21st, 2011
We had recently made changes to a clients network updating the IP range. This required updating the printer IP’s to the new range. The problem however was that every PC over multiple sites was configured with the static IP Address of the printer. What to do? This script creates a new printer port, then assigns the port to the printer of choice. We were able to set this to run on computer startup and everyone was happy. Change the sections in bold as you require.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "NAME"
objNewPort.Protocol = 1
objNewPort.HostAddress = "127.0.0.1"
objNewPort.PortNumber = "9100"
objNewPort.SNMPCommunity = "public"
objNewPort.SNMPDevIndex = 1
objNewPort.SNMPEnabled = True
objNewPort.Put_
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"))
Set colPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where DeviceID='PRINTER NAME'")
For Each objPrinter in colPrinters
objPrinter.PortName = objNewPort.Name
objPrinter.Put_
Next
Permalink: http://www.connectivityit.com.au/2011/12/21/updating-printer-configurations/
