Quantcast
Channel: Active Directory & GPO
Viewing all articles
Browse latest Browse all 20789

why my scripts to map network drive by individual username does not work?

$
0
0

I wrote the script as shown below. but it does not work. It always stop at line

"For Each UserString In UserObj.Groups
Select Case userstring"

Scripts..

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, GroupObj, UserObj, objsysinfo, Path, wshenvironment

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
Set objSysInfo = CreateObject("ADSystemInfo")

'Automatically find the domain name
Set objDomain = getObject("LDAP://rootDse")
DomainString = objDomain.Get("dnsHostName")

'Find the user name
UserString = WSHNetwork.UserName

'Bind to the user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

' Currently logged in User
'Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
' or specific user:
'Set objUser = GetObject("LDAP://CN=johndoe,OU=Users,DC=ss64,DC=com")


'Find the computer name for use in add-on code later
strComputer = WSHNetwork.ComputerName

'strUserDN = objSysInfo.UserName

strAdsPath = "LDAP://" & strUserDN

'Synchronizes the time with Server our NTP Server


'==================== Now check for specific user and map appropriate drives =============================
For Each UserString In UserObj.Groups
Select Case userstring


Case "yvonne.Tan"
WSHNetwork.MapNetworkDrive "Y:", "\\ap-sgp-File-01\Marketing",True
WSHNetwork.MapNetworkDrive "Z:", "\\ap-sgp-File-01\Communication",True

Case "honglin.tan"
WSHNetwork.MapNetworkDrive "T:", "\\ap-sgp-term-01\tfs",True


Case "Shirley.Tan"
WSHNetwork.MapNetworkDrive "R:", "\\ap-sgp-app-01\readyhr",True

Case "Hazel.Tan"
WSHNetwork.MapNetworkDrive "R:", "\\ap-sgp-app-01\readyhr",True

End select
Next

'=================================================================================================
'Add On Code goes above this line

'FIN:

'Clean Up Memory We Used
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing

Wscript.Sleep 50
objExplorer.Quit

'Quit the Script
wscript.quit


Viewing all articles
Browse latest Browse all 20789


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>