timbo343 Posted April 17, 2015 Posted April 17, 2015 (edited) So I have our printers mapped to computers via a VB Script. Here are 2 parts of the script which adds the printer to the machine if they meet the computer name: 'ICT08 Computers Select case (Left(computername,6)) Case "room03" wshnetwork.addwindowsprinterconnection "\\server\printer" wshnetwork.setdefaultprinter "\\server\printer" End Select 'ICT08 Computers ' IT Support - Member of group in AD If Instr(strGroups,itsupport) then wshnetwork.addwindowsprinterconnection "\\server\printer1" wshnetwork.addwindowsprinterconnection "\\server\printer2" wshnetwork.setdefaultprinter "\\server\printer1" End If 'itsupport - Member of group in AD What im wanting to do is to add a bit more to the requirements so that if the user is in group "year2010" they get another printer, I guess I need a "IF", "AND" statement working with the "SELECT CASE" statement. How would I add this in? Thanks Edited April 17, 2015 by timbo343
mac_shinobi Posted April 17, 2015 Posted April 17, 2015 PM Sent - didn't want to post the script on here because it had server names etc but see if that script helps you out at all ? 1
timbo343 Posted April 17, 2015 Author Posted April 17, 2015 Cheers for the PM, will have a look through it. 1
mac_shinobi Posted April 17, 2015 Posted April 17, 2015 no problem - If I remember correctly I made the adding a printer and setting it as default a function or something to that effect and then basically just got it to detect the computer name and depending on the computer name called the add printer function / sub ( whatever it was ) to add the relevant printer ( which required the unc path to the print server and also the share name of the printer you wanted to add ) Will make more sense when you open the vb script up and see the code etc, obviously edit / update the code to your needs etc
timbo343 Posted April 21, 2015 Author Posted April 21, 2015 Just had a look over the script. I think I have what you already have but what I want to do is add a "Student Coursework" printer to a specific room when the user is in intake2010. If a user is in Intake2011 logs In when in the same room, they don't get the "Student Coursework" printer.
mac_shinobi Posted April 21, 2015 Posted April 21, 2015 Just had a look over the script. I think I have what you already have but what I want to do is add a "Student Coursework" printer to a specific room when the user is in intake2010. If a user is in Intake2011 logs In when in the same room, they don't get the "Student Coursework" printer. Is intake2010 and intake2011 different security groups or are they different OU's ?
timbo343 Posted April 21, 2015 Author Posted April 21, 2015 (edited) They are different security groups. Edited April 21, 2015 by timbo343
mac_shinobi Posted April 21, 2015 Posted April 21, 2015 Will need something like this to check the group membership of the user account to see if it is a member of the intake2010 or intake2011 etc and if so then to add whatever printer you want : You would most likely need to edit the script as you can use your select case etc to do what you need IsMember Function (VBScript)
timbo343 Posted April 22, 2015 Author Posted April 22, 2015 Managed to get it to work after thinking about it. I was trying to get the the select case into the If statement, so what i have done is flipped its on its head and thought, how about check the computer name then check the security group, here it is. I think i was over thinking it to be honest. Select case (computername) Case "*ComptuerName*" If instr(strGroups,*SecurityGroup*) then wshnetwork.addwindowsPrinterConnection "\\server\printer1" wshnetwork.addwindowsprinterconnection "\\server\printer2" wshnetwork.setdefaultprinter "\\server\printer1 End If End Select
halbaradkenafin Posted April 22, 2015 Posted April 22, 2015 For future reference you can achieve the same effect with Group Policy Preferences and Item Level Targeting. We've got it set up for a few users to allow us to dictate which ones are the default printer so they override the normal choice and instead use the one sitting next to them. You can target based on user, group or device.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now