Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Script to move computers from one print server to new print server

Hi,
Looking for a script to move computers from one print server to another print server (Both Windows Servers, moving from x86 to x64 architect). the script should move the queue for users to new server as well.
the printers are located on 3 different floors, on each floor there are around 30 users.
thanks.
0
Leo
Asked:
Leo
  • 8
  • 7
2 Solutions
 
serialbandCommented:
Wouldn't it have been easier to do with group policy?  Do you have AD?

Someone has a powershell script to do that.
http://learn-powershell.net/2012/11/15/use-powershell-logon-script-to-update-printer-mappings/
0
 
LeoAuthor Commented:
We have AD, but this script needs to be run as a logon script, and only few floors are getting migrated to new printer, so if i run that script it will map all the users to new printer, correct me if i am wrong?
We dont have individual Group policy for each floor, the printers are added through logon script, so i am after a script which can be used as a logon script to map to new server and delete the old printer...
0
 
RobSampsonCommented:
Hi, I've used the script linked to in this thread to migrate printers from one server to another. It involves mapping your printers in an old share to new share manner, and so only changes print queues that are mentioned in the list.
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/Q_27093481.html

Regards,
Rob.
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
LeoAuthor Commented:
Hi, just few questions on the script that you suggested can be used....
strLogFileShare = "\\FileServer\userlogins$\PRINTSVR1_printer_changes\"
"userlogins$" whats this for?

  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
What does this command do?

"\\PRINTSVR1\CroydonCivic_LocalLaws1:\\PRINTSVR2\CroydonCivic_NeighborhoodServices1", _
      "\\PRINTSVR1\By_Laws_2300LH:\\PRINTSVR2\CroydonCivic_NeighborhoodServices1", _
      "\\PRINTSVR1\By_Laws_2300:\\PRINTSVR2\CroydonCivic_NeighborhoodServices1", _

This means its moving few different printers to new server, right? in my case printers are mapped at logon script, and each floor have its own printer, so I will be just using one array....right?

'MsgBox "Done" Where does this message gets send?
0
 
RobSampsonCommented:
Hi, the userlogins$ part is just the share name of a shared folder on \\FileServer\
PrintSVR1_printer_changes is another folder inside that shared folder.

The impersonationLevel is a WMI moniker.  WMI is used to connect to the machine to query the attached printers.

You can use one array for the entire script.  Basically what it does is enumerates all of the network printers that a user has connected when they log on, and if a match is found on the left side of the colons, that printer will be replaced by the printer on the right side of the colon.

I am concerned though, that the print queues to be replace are *still* being mapped at logon, this will need to run *after* that script.

Rob.
0
 
LeoAuthor Commented:
"\\FileServer\userlogins$\PRINTSVR1_printer_changes\" so its just a share name for the printer?
With the Array, do i have to define for each floor which printer they are attached to? means...
      "\\OldServer\Floor13:\\NewServer\Floor13", _
0
 
RobSampsonCommented:
Hi, I will try to explain it a bit better for you to understand how it works.

This line:
strLogFileShare = "\\FileServer\userlogins$\PRINTSVR1_printer_changes\"

points to a folder on a server share (public share), that every user needs to have write access to, In that folder, a file is created called <username>.txt, which is used purely for logging purposes, for you to check which user has had which printers remapped.

The Set objWMIService line initiates a WMI connection, and the Set colPrinters = objWMIService.ExecQuery line makes a WMI call to query the Win32_Printer class to retrieve any currently mapped printer (for the logged on user) that is NOT a local printer, ie, it is a network mapped printer.

The array in the middle of that is where the main configuration needs to take place.  You will see that each line in the array contains a colon.  On the left side of this colon is where you would type the queue name of the printer that is being replaced, and you don't want users to print to anymore.  On the right side of the colon is where you would type the queue name of the printer that is replacing the first one.  The two queue names can be completely different, the script simply removes the connection for the first, and replaces it with a connection to the second.

You can enter all of the old printers you are replacing, and all of the corresponding new printers.  Any printer that a user has mapped, that is NOT listed in the first element of each line, will not be touched.  That printer will still remain mapped for every user that already has it.

If you want to test it with just one printer, set the array to
arrPrinterShares = Array( _
      "\\PRINTSVR1\OldPrintQueue1:\\PRINTSVR2\NewPrintQueue1" _
)

and then keep an eye on the logging folder (set by strLogFileShare) to see what it is doing with users printers.

Hopefully that answers any questions you have.

Regards,

Rob.
0
 
LeoAuthor Commented:
Thanks.
kindly see the attached script, if i am doing it for one floor, one printer...would this be ok?
and i will be only making changes in the PrintSvr name....right?
0
 
LeoAuthor Commented:
0
 
RobSampsonCommented:
Correct, so what you have is:
strLogFileShare = "\\FileServer\userlogins$\PRINTSVR1_printer_changes\"

so that when a user logs on and a printer listed in arrPrinterShares is found, the change will be logged to that share.

You also have this:
arrPrinterShares = Array( _
      "\\PRINTSVR1\OldPrintQueue1:\\PRINTSVR2\NewPrintQueue1" _
)

so for any user (no matter what their location is, as long as they are running the script) that has \\PRINTSVR1\OldPrintQueue1 mapped, will have that removed, and replaced with \\PRINTSVR2\NewPrintQueue1, and it will be logged as above.

Remember that any user that is not connected to that printer, will not have their connected printers modified in any way.  Only the listed printers will be changed.

Regards,

Rob.
0
 
LeoAuthor Commented:
ok, so the script will automatically create this folder "userlogins$" if they dont have it already?
0
 
RobSampsonCommented:
No. The shared folder that you specify on that line must exist, and be writable to all users.
0
 
LeoAuthor Commented:
Thanks, is there any folder in windows which is writable for all users?
because at my current workplace they dont have anything specific setup like that.......
0
 
RobSampsonCommented:
It's just a shared folder, so if you don't have a server that you can share a folder on to all users, then you should be able to select a client (eg your computer), and create a shared folder.  Otherwise, change the line to
strLogFileShare = "C:\Users\Public\Documents\"

but you will need to visit each PC to be able to know whether changes were made.

Rob.
0
 
LeoAuthor Commented:
ok, that will be a long procedure :-(
can this folder can be created on the server and i can give all staff full access to it, and when the script runs it logs the information based on there computer name into that folder?
0
 
RobSampsonCommented:
Yes. Create a shared folder with Write access for Domain Users, and point that line yo that shared folder.  As a test for yourself, manually connect yourself to the shared printer you are replacing, then run the script to make sure it works.

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now