Script Mapping all Drives

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I found this script online and it works but it maps all the drives not just
those for a group. We we have 2003 R2 AD. Any Ideas?

On Error Resume Next

Dim GroupList
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")

GetGroupInfo()

LogonPath = fso.GetParentFolderName(WScript.ScriptFullName)

'**************************************Group Mappings Based on
Grouplist.csv*********************************

If fso.FileExists(logonpath&"\Grouplist.csv") Then
Set grplist = Fso.OpenTextFile(logonpath&"\Grouplist.csv")
'make File into an Array
aGroup = Split(grplist.Readall,vbcrlf)
For I = 0 to UBound(GroupList) ' Check Every Group Membership the user is
in (populated into Grouplist)
grpname = Grouplist(i)
For x = 0 to UBound(aGroup) ' Read the entire CSV to make sure all drives
are mapped for each Group
mapline = aGroup(x)

If InStr(LCase(mapline),LCase(grpname)) Then ' If you're in the group
mapline = Mid(mapline,InStr(mapline,",")+1) ' Remove the GroupName
from the line
Drive = Left(mapline,InStr(mapline,",")-1) ' Extract Drive Letter
Path = Mid(mapline,InStr(mapline,",")+1) ' Extract the path



'If (fso.DriveExists(drive)= True)Then ' Ifthe drive mapping is stale,
remove it
' WshNetwork.RemoveNetworkDrive Drive
' drive,true,true
'End If


'If (fso.DriveExists(drive) <> True) and (Drive<>"!!") Then ' If The
Drive is not already mapped
WshNetwork.MapNetworkDrive drive,path,false ' Map The Drive
wscript.sleep 1000

'End If


' If Drive = "!!" then
' WSHNetwork.AddWindowsPrinterConnection Path
' wscript.sleep 1000
'end if
'End If
End IF
Next
Next
End IF

Sub GetGroupInfo
Set UserObj = GetObject("WinNT://" & wshNetwork.UserDomain & "/" &
WshNetwork.UserName)'WinNT
Set Groups = UserObj.groups

For Each Group In Groups
GroupCount = GroupCount + 1
Next

ReDim GroupList(GroupCount -1)
i = 0
For Each Group In Groups
GroupList(i) = Group.Name
i = i + 1
Next
End Sub


.



Relevant Pages

  • Re: Help!!!
    ... I would suggest you start small with a script that simply maps a few ... drives unconditionally. ... > System maps N drive to system server + apps$ unless in group BlockNDrive ...
    (microsoft.public.scripting.wsh)
  • Re: Shared drives do not properly function as before... Missing files.
    ... >All other computers see the dhsed drive, ... In the maps of the shared drives every lately updated 'client' machine ... >does not see all files in all maps anymore. ... This 'client' DOES SEE ALL ...
    (microsoft.public.windowsxp.network_web)
  • Shared drives do not properly function as before... Missing files.
    ... All other computers see the dhsed drive, ... In the maps of the shared drives every lately updated 'client' machine ... This 'client' DOES SEE ALL ...
    (microsoft.public.windowsxp.network_web)
  • Re: Mapped Drives using Group Policy Issue
    ... you have used Group policy prefernces to map drives and now with removing the preference the mapping still stay? ... I was using the "drive maps" option 1st and whenever i ... "diffname on fileserver" the display would continue to read "shared on ...
    (microsoft.public.windows.server.active_directory)
  • Re: Driving itineraries in France / Loire Valley
    ... The Michelin Green Guides always have drives laid out. ... big foldup maps. ... In the Loire Valley, I reccomend Ambroise as a base. ...
    (rec.travel.europe)