Printer Migration Script
Not sure if you've every had an issue where you have to move printers from one print server to another... I have had this come up a couple times...
Here's a little vbs that can be executed from a logon script, that will look at a mapped printer's connection (which server it is on), remove it, and then map it to another system.
Keep in mind, all the printers on NEWSERVER must have the same share names as the OLDSERVER.
Basically this script enumerates each printer, looks for the server it is mapped from, deletes the printer, and then adds the new printer, which happens to be the same printer, but mapped on a different server.
Here is the code:
As always, you are welcome to use the script, but I will not be held liable if any issues arise.
Here's a little vbs that can be executed from a logon script, that will look at a mapped printer's connection (which server it is on), remove it, and then map it to another system.
Keep in mind, all the printers on NEWSERVER must have the same share names as the OLDSERVER.
Basically this script enumerates each printer, looks for the server it is mapped from, deletes the printer, and then adds the new printer, which happens to be the same printer, but mapped on a different server.
Here is the code:
On Error Resume NextIf you want to download it, you can find it here.
Dim strComputer
Dim objWMIService
Dim colItems
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)
For Each objItem in colItems
If objItem.ServerName = "\\OLDSERVER" then
WshNetwork.RemovePrinterConnection objItem.ServerName & "\" & objItem.ShareName, true, true
WshNetwork.AddWindowsPrinterConnection "\\NEWSERVER\" & objItem.Sharename
End If
Next
As always, you are welcome to use the script, but I will not be held liable if any issues arise.
Labels: VBS Windows

1 Comments:
Very nice, simple script. I've looked at lots of scripts trying to migrate client printers and none of them have worked. Great job!
Post a Comment
Links to this post:
Create a Link