Skip to content

Instantly share code, notes, and snippets.

@shwangdev
Created October 16, 2011 09:59
Show Gist options
  • Save shwangdev/1290721 to your computer and use it in GitHub Desktop.
Save shwangdev/1290721 to your computer and use it in GitHub Desktop.
CreateDomainUser.vbs
Dim objRoot, objDomain, objOU, objContainer
Dim strName
Dim intUser
Dim Password
Dim OUPrefix
Dim OU
Dim Inc
Inc = 1
OUPrefix = "TMMS"
strName =""
Password = "tmmsmac8.6"
Set objRoot = GetObject("LDAP://rootDSE")
Set objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objOU=objDomain.Create("organizationalUnit", "ou=TMMS"&Inc)
objOU.Put "Description", "Guy's Bulk Users OU"
objOU.SetInfo
Set objContainer = GetObject("LDAP://OU=TMMS" & Inc&"," & _
objRootDSE.Get("defaultNamingContext"))
' Create User account
For account = 13900000001 To 13901000000
Set objLeaf = objContainer.Create("User", "cn=" & strName & account)
objLeaf.Put "sAMAccountName", strName & account
objLeaf.SetInfo
objLeaf.SetPassword password
objLeaf.AccountDisabled = FALSE
objLeaf.SetInfo
intUser = intUser +1
If intUser mod 2000 = 0 Then
Inc = Inc +1
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objOU=objDomain.Create("organizationalUnit", "ou=TMMS"&Inc)
objOU.Put "Description", "Guy's Bulk Users OU"
objOU.SetInfo
Set objContainer = GetObject("LDAP://OU=TMMS" & Inc&"," & _
objRootDSE.Get("defaultNamingContext"))
End If
Next
WScript.Echo intUser & " Users created "
WScript.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment