Is this what you are looking for? This script will configure the Home Drive setting within a User Accounts properties in AD.
' Setting Home Directory for multiple users in a specific OU
Dim oContainer
LDAPprefix = "LDAP://"
LDAPsuffix = "OU=<ouName>,DC=<domainName>,DC=<domain>"
Set oContainer=GetObject(LDAPprefix & LDAPsuffix)
' Running the ModifyUsers Subroutine on the container
ModifyUsers(oContainer)
' Clean up
Set oContainer = Nothing
' Display a message box upon operation complete
MsgBox "Finished :O)"
' Close
WScript.Quit
Sub ModifyUsers(oTopLevelContainer) ' oTopLevelContainer is the oContainer object
Dim oObj
' Go into a loop for every object in the container
For Each oObj in oTopLevelContainer
' We use "Select Case" to apply different code/actions to different values of an item. In
' this case, we check every object's Class to apply the actions according to the Object's
' class, e.g. If it's a user object, it goes into the 'Case "user"' section.
On error resume next
Select Case oObj.Class
Case "user"
'MsgBox LDAPprefix & oObj.Name & "," & LDAPsuffix
Set oUser = GetObject(LDAPprefix & oObj.Name & "," & LDAPsuffix)
oUser.Put "homeDirectory","\\serverpath\" + oUser.SamAccountName
oUser.Put "homeDrive", "u:"
oUser.Setinfo
' If it's a container/OU, go into the ModifyUsers loop for every object there
Case "organizationalUnit" , "container"
ModifyUsers(oObj)
End select
' Goes into the next available child object under the container
Next
End Sub
I hope you find this post helpful. Please let me know if it was.
Regards,
Mark