RATE THIS ANSWER
0
Click to Vote:
0
0
Hello WinComputingATE,
hereafter a couple of tips that may help you in getting this things done.
1st script creates a file called MyUsers.txt containing the local usernames.
set objFSO=CreateObject("Scripting.FileSystemObject")
set objFile=objFSO.CreateTextFile("MyUsers.txt",TRUE)
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
objFile.WriteLine objUser.Name
Next
objFile.Close
MsgBox("Finished exporting users",vbOKOnly+vbInformation,"Exported Users")
2nd script: Reads data from the text file and adds them to the domain.
Const ForReading=1
Const strPass = "initialpassword"
Set objRoot = GetObject("LDAP://RootDSE")
strDomainPath = objRoot.Get("DefaultNamingContext")
strContainer="CN=MyUsers"
strFile="MyUsers.txt"
set objFSO=CreateObject("Scripting.FileSystemObject")
set objFile=objFSO.OpenTextFile(strFile,ForReading)
do While objFile.AtEndOfStream<>True
strEntry = objFile.ReadLine
CreateUser strEntry
loop
objFile.Close
Sub CreateUser(strUser)
set objContainer=GetObject("LDAP://" & strContainer & "," & strDomainPath)
set objUser=objContainer.Create ("User","cn=" & strUser)
objuser.Put "samAccountName",strUser
objUser.SetInfo
objUser.SetPassword(strPass)
objUser.Put "PasswordExpired", 1
objUser.SetInfo
End Sub
I hope this helps.
P.S. I suggest you to first create a test environment where you can try this before going
live with this solution.
To build the test-lab you can use the
VMWare Server and
VMWare Converter.
With the converter you can create a virtual machine that is the exact copy of your running server, then you mount this virtual machine in VMWare Server and perform your tests.