Jump to content

VB Script to check if someone is member of a group then map a drive if they are?


Recommended Posts

Posted

Is there an easy way to do this at all?!?!

 

Want to create a new single logon script instead of using the 20 we have at the moment. Want to map drives depending on what groups they are members of.

 

Is there an easy way to do this?!?!

 

Hope you can help!

Posted

A GUI based alternative is Group Policy Preferences (GPP) that can do this for you...

 

Works with Server 2003 upwards...

Windows XP with update patch, or Windows 7 upwards...

 

Just need a Windows 7 Client to configure the GPP within your Group Policies.

Posted (edited)

pretty universal login script here...

' Get current username
strUser = ""
Do While strUser = ""
   strUser = objNetwork.UserName
   WScript.Sleep 100
Loop


set objUser = GetObject("WinNT://CORPORATE/" & strUser &",User")


' Enumerate Group Membership
strGroups = ";"
For Each objGroup In objUser.Groups
  strGroups = strGroups & objGroup.Name & ";"
Next


' the command
MapGroup "Training", "T:", "\\SAN\Group$\Training"


' Uses the MapDrive function to map a network drive for a particular user group.
'
Sub MapGroup(strGPName, strDrive, strShare)
  Const vbTextCompare = 1
  If InStr(1, strGroups, strGPName, vbTextCompare) > 0 Then
  MapDrive strDrive, strShare
  End If
End Sub

Edited by bytejunkie

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...