I was recently given the login script sample below for a previous question and it works great. I am now looking to add to the login script and was looking for help on the syntax. I'm looking to map a drive based on a user being in a specific group in AD. I'm sure it's possible. Something like if you're part of the general ledger group then map a drive to the general ledger share. Any help would be greatly appreciated.
With a VBS file, you can use the WSH Network object to return the username, so you can use the same approach as a Batch file's %username% value.
Dim wshNetwork, objFSO
Set wshNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.DriveExists("h:") = True Then wshNetwork.RemoveNetworkDrive "h:"
If objFSO.DriveExists("m:") = True Then wshNetwork.RemoveNetworkDrive "m:"
If objFSO.DriveExists("o:") = True Then wshNetwork.RemoveNetworkDrive "o:"
If objFSO.DriveExists("s:") = True Then wshNetwork.RemoveNetworkDrive "s:"
wshNetwork.MapNetworkDrive "h:", "\\filesrv\users\" & wshNetwork.UserName
wshNetwork.MapNetworkDrive "m:", "\\filesrv\data"
wshNetwork.MapNetworkDrive "o:", "\\filesrv\masters"
wshNetwork.MapNetworkDrive "s:", "\\filesrv\shared"