There are a few different ways to map drives when a user logs in, if you already have a log in script you can simply copy parts of the following code into the script to be able to map drives.
This is a very simple script, when it comes to login scripts, the less complex the better as troubleshooting and loading times are reduced!
' ####################################
' # %company% login script #
' # Author: Chris Reeves #
' ####################################
' # Change Log #
' ####################################
'
' ver initial date / Description
'------------------------------------------------------------------------------
' 0.1 XX %%%%%% / Inital script created, header and change log created
' added mapping drives based on group membership.
' 0.2 XX %%%%%% / Changed x and y drive maps to X and Y.
'
'
' # Active Directory group membership script
'
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
'
' # Drive mapping segment
'
Select Case strGroupName
Case "GROUP NAME HERE"
objNetwork.MapNetworkDrive "S:", "\123.456.789.001share1$"
Case "GROUP NAME HERE"
objNetwork.MapNetworkDrive "T:", "\123.456.789.001share2$"
End Select
Next
'
' # Script Complete
Modifications
You will need to change the following:
Group Name Here
Change these strings to the group name you wish to use to map to the location.
\123.456.789.001share#$
Configuring in Active Directory
Netlogon
You will need to copy the script file to the \activedirectoryservernetlogon path and ideally call the file something like login.vbs
User Management
You will need to type the file name only into the “Login Script” path under the profile tab in the Active Directory users profile.
Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.
























