'VBScript
'* description: create AD user accounts from the text file created by the export script.
'* author: Chris Pilling.
'* date: 18 June 2008.
'* I create an OU called import to create the accounts in then move the users around using dsa.msc.
'* REMEMBER to delete system generated accounts from the text file before running.
'* This script will quit if an account in the text file duplicates an existing one.
'* you will need to edit the FQDN for the UPN in the text file if your new AD is different from the
' one you exported from.
on error resume next
Const ADS_UF_NORMAL_ACCOUNT = 512
Dim strL
Const ForReading = 1
Set objRoot = GetObject("LDAP://RootDSE")
varDomainNC = objRoot.Get("DefaultNamingContext")
Set objDomain = GetObject("LDAP://" & varDomainNC)
'* edit the line below to match your FQDN
'AP-Auth-Test.local
Set objOU = GetObject("LDAP://ou=wireless,dc=lginnotek,dc=com")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ts = objFSO.OpenTextFile("d:\script\emp_list.txt", ForReading)
Do until ts.AtEndOfStream
strL = ts.ReadLine
spl1 = Split(strL, ",")
'* edit the line below to match your FQDN
Set objOU = GetObject("LDAP://ou=wireless,dc=lginnotek,dc=com")
Set objUser = objOU.Create("User", "cn =" & (left(spl1(4),InStr(spl1(4),"@")-1)))
wscript.echo left(spl1(4))
objUser.Put "sAMAccountName", (left(spl1(4),InStr(spl1(4),"@")-1))
objUser.Put "UserPrincipalName", (spl1(4))
wscript.echo "======================================="
wscript.echo "SSO ID=" & spl1(4)
wscript.echo "Password=" & right(spl1(2),7) & " SID NO= " & spl1(2)
objUser.SetInfo
'Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objFile = objFSO.CreateFolder("\\windows2003\users" & "\" & (spl1(0)))
'Set objFile2 = objFSO.CreateFolder("\\windeows2003\profiles" & "\" & (spl1(0)))
objUser.AccountDisabled = FALSE
'* edit the password to suit
objUser.SetPassword(right(spl1(2),7))
objUser.SetInfo
wscript.echo spl1(0) & spl1(1) & spl1(2) & spl1(3) & spl1(4)
wscript.echo ((left(spl1(4),InStr(spl1(4),"@")-1))) & "," & (spl1(0)) & ","
wscript.echo "error code=" & Err.Number
Err.Clear
Loop
'IT Professional > Windows Management Technology' 카테고리의 다른 글
Crash Dump 의 수집 (0) | 2012.11.19 |
---|---|
문제가 발생하는 시점에서 자료 수집 (0) | 2012.11.16 |
AD User Password reset script (0) | 2010.02.25 |
Ad Password 변경 Script (7) | 2010.02.24 |
말도 많도 탈도 많은 Hyper-V 이야기 : 첫번째 (0) | 2010.02.15 |