Jump to content

Recommended Posts

Posted

I've got a stand alone windows 2003 server whos functions are being migrated to another 2003 server, again stand alone and non-DC.

The current server has several hundread users on it which I've exported as a simple list of usernames and as an excel sheet with "username" "fullname".

I've managed to cobble together a script that'll create all the local users and then another that a second to drop them into the correct groups.

Create users


strComputer = "lmuklap"
strServerListFile="user.txt"
set fs = CreateObject("Scripting.FileSystemObject")
set fl = fs.openTextFile(strServerListFile)
while not fl.atEndOfStream
strUser=fl.readLine
'wscript.echo strUser
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user",strUser)
objUser.SetPassword "password"
objUser.SetInfo
objUser.Put "PasswordExpired", 1
objUser.SetInfo
wend
fl.close
wscript.echo "done"

Add to groups


strComputer = "lmuklap"
strServerListFile="user.txt"
strGroup = "users"
set fs = CreateObject("Scripting.FileSystemObject")
set fl = fs.openTextFile(strServerListFile)
while not fl.atEndOfStream
strUser =fl.readLine

' Get group object
Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ",group")
' Get user object
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
' Add user to group
objGroup.Add(objUser.ADsPath)
wend
fl.close
wscript.echo "Done"

Firstly I know this is somewhat rough so anypointers are apprecieated.

Ideally I'd like to be able to pull the user list from an xls file and refference colum A (username) and colum B (full name) to get both fields added when creating the user account.

If there's a way of merging the two scripts too with the addition of adding the users to a second group, that'd be handy.

Advice please of wise internet.


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...