Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLS review my script - Drive mapping based on Group Membership 1

Status
Not open for further replies.

brendaluv

Technical User
Dec 2, 2002
144
CA
Hi...the following script will map the first drive ONLY, the second statement does not map. We have 2x checked the Group Membership and share access. (able to map using Windows Explorer.

NOt sure at this point why the second drive is not mapping?!?!

any help would be awesome!

:)

' CAS-GrpMapDrive.vbs
' Script Maps network drive based on group members ship for a user and it is paplied to entire domain.
' ------------------------------------------------------------------------------------------------------'
Option Explicit
' On Error Resume Next
Dim objNetwork, objUser, CurrentUser
Dim strGroup

' Initialise any existing or new secuirty group that will need custom drive mapping
' [Copy and paste the existing line and then change the group name on both side of "=" sign]
Const Appeals = "cn=Appeals"
Const Modernization = "cn=Modernization"

' Create objects and extract strGroup values
' DO NO MAKE ANY CHANGES HERE
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
strGroup = LCase(Join(CurrentUser.MemberOf))

' Para 1
' P: Drive for Appeals Group
If InStr(strGroup, lcase(Appeals)) Then
WScript.Echo "Appeals: " & strGroup
objNetwork.MapNetworkDrive "p:", "\\tcc-usersdata\appeals"


' Para 2
' P: Drive for Modernization Group
ElseIf InStr(strGroup, lcase(Modernization)) Then
WScript.Echo "Modernization: " & strGroup
objNetwork.MapNetworkDrive "h:", "\\tcc-usersdata\Modernization"



' If you like to add more Group based mappping, all you have to do is copy the contents of "Para 2"
' and modify the group and Network drive mapping

End If
WScript.Quit

' End of example VBScript .

 
Perhaps this ?
' Para 1
' P: Drive for Appeals Group
If InStr(strGroup, lcase(Appeals)) Then
WScript.Echo "Appeals: " & strGroup
objNetwork.MapNetworkDrive "p:", "\\tcc-usersdata\appeals"
[!]End If[/!]
' Para 2
' P: Drive for Modernization Group
[!]If[/!] InStr(strGroup, lcase(Modernization)) Then
WScript.Echo "Modernization: " & strGroup
objNetwork.MapNetworkDrive "h:", "\\tcc-usersdata\Modernization"
End If


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top