Orcie
04-05-2004, 02:53 AM
Hi,
I'm writing a script that has to add users to the active directory with a homemap and permissions.
The script I have so far only works to add 1 user, can anyone help me out to let it add mutiple users by using a Excel spreadsheet or something.
Tnx on avance for the help.
Orcie
Here's the script I have so far:
======================================
Option Explicit
Const WAIT_ON_RETURN = True
Const HIDE_WINDOW = 0
Const USER_ROOT_UNC = "\\testserver\users$\" 'Set Home Folder Location Here
Dim WshShell, WshNetwork, objFS, objOU, objServer, objShare, usr, struser
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objOU = GetObject("LDAP://CN = users,DC = wshserver,DC = lokaal")
'Create the User
Set usr = objou.Create("user", "CN=Testgebruiker02")
usr.Put "samAccountName", "Testgebuiker02"
usr.Put "sn", "Testgebruiker02"
usr.Put "givenName", "Testgebuiker02"
usr.Put "userPrincipalName", "Testgebruiker02@wshserver.lokaal"
usr.Put "telephoneNumber", "(456) 456 4572"
usr.Put "title", "Sir"
usr.SetInfo
'Now that the user is created, reset the user's password and enable its account.
usr.SetPassword("changeme")
usr.AccountDisabled = False
usr.SetInfo
'Now create the User's Home Folder and set permissions.
strUser = usr.samAccountName
Call objFS.CreateFolder(USER_ROOT_UNC & strUser)
Call WshShell.Run("cacls " & USER_ROOT_UNC & strUser & _
" /e /g Administrators:F", HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & USER_ROOT_UNC & strUser & _
" /e /g " & strUser & ":C", HIDE_WINDOW, WAIT_ON_RETURN)
======================================
I'm writing a script that has to add users to the active directory with a homemap and permissions.
The script I have so far only works to add 1 user, can anyone help me out to let it add mutiple users by using a Excel spreadsheet or something.
Tnx on avance for the help.
Orcie
Here's the script I have so far:
======================================
Option Explicit
Const WAIT_ON_RETURN = True
Const HIDE_WINDOW = 0
Const USER_ROOT_UNC = "\\testserver\users$\" 'Set Home Folder Location Here
Dim WshShell, WshNetwork, objFS, objOU, objServer, objShare, usr, struser
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objOU = GetObject("LDAP://CN = users,DC = wshserver,DC = lokaal")
'Create the User
Set usr = objou.Create("user", "CN=Testgebruiker02")
usr.Put "samAccountName", "Testgebuiker02"
usr.Put "sn", "Testgebruiker02"
usr.Put "givenName", "Testgebuiker02"
usr.Put "userPrincipalName", "Testgebruiker02@wshserver.lokaal"
usr.Put "telephoneNumber", "(456) 456 4572"
usr.Put "title", "Sir"
usr.SetInfo
'Now that the user is created, reset the user's password and enable its account.
usr.SetPassword("changeme")
usr.AccountDisabled = False
usr.SetInfo
'Now create the User's Home Folder and set permissions.
strUser = usr.samAccountName
Call objFS.CreateFolder(USER_ROOT_UNC & strUser)
Call WshShell.Run("cacls " & USER_ROOT_UNC & strUser & _
" /e /g Administrators:F", HIDE_WINDOW, WAIT_ON_RETURN)
Call WshShell.Run("cacls " & USER_ROOT_UNC & strUser & _
" /e /g " & strUser & ":C", HIDE_WINDOW, WAIT_ON_RETURN)
======================================