Coding Thread, VBS Printer script checking PC Group membership in Coding and Web Development; Hi there,
I'm using some fairly basic vbs login scripts to map my printers in (below). (I've had to resort ...
28th August 2013, 09:59 AM #1
VBS Printer script checking PC Group membership
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
rem ** Setup new printer connection **
rem ** Setup default printer **
28th August 2013, 10:14 AM #2
- Rep Power
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".
28th August 2013, 10:41 AM #3
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
28th August 2013, 10:52 AM #4
- Rep Power
'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
objNetwork.AddWindowsPrinterConnection "\\Print-Server\Staff room-2025n"
objNetwork.AddWindowsPrinterConnection "\\Print-Server\Room5 - HP2600n"
'==========Add addtional case sections for each group above================
4th September 2013, 01:53 PM #5
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?
By SHimmer45 in forum Scripts
Last Post: 14th May 2012, 02:17 PM
Last Post: 1st October 2010, 11:11 AM
By CM786 in forum Windows
Last Post: 11th July 2006, 08:37 PM
By ICTNUT in forum Windows
Last Post: 2nd December 2005, 04:19 PM
Last Post: 15th September 2005, 11:07 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)