Map Network Drives Depending on Group Membership
Maintaining a lot of log-in scripts is a pain, especially the repetition involved in adding someone to a security group (Finance) and then mapping the appropriate network share (\\Server\Finance). I’ve recently switched to VB script instead of batch files. This lets me map network drives automatically based on group membership in active directory:
Dim wshNetwork, ADSysInfo, CurrentUser
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))
If InStr(strGroups, LCase("cn=Finance")) Then
wshNetwork.MapNetworkDrive "F:", "\\SERVER\Finance"
End If
Printers can be mapped as well:
wshNetwork.AddWindowsPrinterConnection "\\SERVER\Printer1"
wshNetwork.AddWindowsPrinterConnection "\\SERVER\Printer2"
wshNetwork.SetDefaultPrinter "\\SERVER\Printer2"
This has been working well so far and is a big time-saver.