Stuart_C Posted August 28, 2013 Posted August 28, 2013 Hi there, I'm using some fairly basic vbs login scripts to map my printers in (below). (I've had to resort back to this becuase GPP has proved to be not as efective as I'd like). Is there a way to find and check a PC's Group membership as part of the script? Specifically I want to see if the PC is a member of a windows security group and if it is apply one setting and if it isn't a different one. Current script for reference rem ** Next line must not be deleted ** Set WshNetwork = CreateObject("WScript.Network") rem ** This will delete existing printers ** On Error Resume Next Set oPrinters = WshNetwork.EnumPrinterConnections For i = 1 to oPrinters.Count - 1 Step 2 WshNetwork.RemovePrinterConnection oPrinters.Item(i) Next rem ** Setup new printer connection ** WshNetwork.AddWindowsPrinterConnection "\\\" rem ** Setup default printer ** WshNetwork.SetDefaultPrinter "\\\"
vortex999 Posted August 28, 2013 Posted August 28, 2013 My VBS Script for students maps printers based on the OU that the PC is located in, so they only get the printer for the particular room they in at a time. would this be any help? And my staff one applies printers based on the users membership to the security group "staff".
Stuart_C Posted August 28, 2013 Author Posted August 28, 2013 It might help, possibly the staff one... Basically I need to apply all the printer mappings to all the classroom PC's however I don't want to set a default if there is a local printer. As all the PC's with local printers are members of my papercut group they are easy to find, however they are scattered throughout the OU's
vortex999 Posted August 28, 2013 Posted August 28, 2013 'Printer vbs for logon script 'determines the user who just logged on Set objSysInfo = CreateObject("ADSystemInfo") Set objNetwork = CreateObject("Wscript.Network") 'As soon as we tack on LDAP:// and construct an ADsPath we then bind to the user account in 'Active Directory and report back the groups the user belongs to; this can be done simply 'by enumerating the values in the MemberOf attribute. strUserPath = "LDAP://" & objSysInfo.UserName Set objUser = GetObject(strUserPath) For Each objGroup in objUser.Groups strGroupName = objGroup.CN 'Mapping of printers by group and set default printer for that group Select Case strGroupName Case "Staff" objNetwork.AddWindowsPrinterConnection "\\Print-Server\Staff room-2025n" objNetwork.AddWindowsPrinterConnection "\\Print-Server\Room5 - HP2600n" '==========Add addtional case sections for each group above================ End Select next
Stuart_C Posted September 4, 2013 Author Posted September 4, 2013 Cheers for that. It's worked great for staff however I've hit a slight issue. I can adapt it to return the PC's DN but I can't get it to return the group membership of the PC so I can perform actions if a PC is in certain groups... and suggestions?
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