-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMappings by Groups.vbs
More file actions
45 lines (36 loc) · 1.45 KB
/
Copy pathMappings by Groups.vbs
File metadata and controls
45 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
' Example script that maps drives and printers based on Active Directory
' group membership.
' Note: VBScript is case sensitive when doing a string comparison. I've chosen
' to convert the group membership to an uppercase string. That's why the
' group relative distinguished names are in all caps.
Option Explicit
Dim oADSystemInfo, oUser, oNetwork, sGroups
Const groupHR = "CN=HR"
Const groupMan = "CN=MANAGERS"
Const groupIT = "CN=IT"
Set oADSystemInfo = CreateObject("ADSystemInfo")
Set oUser = GetObject("LDAP://" & oADSystemInfo.UserName)
' Test to see if this user is a member of more than one group.
' Note: Domain Users doesn't get counted.
If IsArray(oUser.MemberOf) Then
sGroups = UCase(Join(oUser.MemberOf))
Else
sGroups = UCase(oUser.MemberOf)
End If
'Map a common drive for everyone
Set oNetwork = CreateObject("WScript.Network")
oNetwork.MapNetworkDrive "P:", "\\denver\all"
'Enum group memberships and map drives and printers using WSH
If InStr(sGroups, groupHR) Then
oNetwork.MapNetworkDrive "M:", "\\denver\hr"
'oNetwork.AddWindowsPrinterConnection "\\<server>\<share>"
'oNetwork.SetDefaultPrinter "\\<server>\<share>"
End If
If InStr(sGroups, groupMan) Then
oNetwork.MapNetworkDrive "I:", "\\denver\man"
End If
If InStr(sGroups, groupIT) Then
oNetwork.MapNetworkDrive "K:", "\\denver\it"
'oNetwork.AddWindowsPrinterConnection "\\<server>\<share>"
'oNetwork.SetDefaultPrinter "\\<server>\<share>"
End If