Jump to content

Adding Users Using Script


kevan79

Recommended Posts

OK, I'm back to suck more knowledge from the board.

I've found alot of this script from both microsoft and a couple websites.

My questions is, how do I program it to read the OU name from, say column 1 of an Excel document? Also, if the OU didn't exist, is there a way for it to make it?

Once again, thanks to all those that are so helpful on this board.

Also, is there anything that I'm leaving out that really should be in there?

NOTE: I've not gotten to test any of this out, as I'm working at it at home.

'script to read user information from an Excel File and add them to the domain

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
   ("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
   Set objOU = GetObject("ou=Data, dc=deployed.af, dc=mil")
   Set objUser = objOU.Create _
       ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
   objuser.userPrincipalName = objExcel.cells(intRow, 9).value
   objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
   objUser.GivenName = objExcel.Cells(intRow, 3).Value
   objUser.SN = objExcel.Cells(intRow, 4).Value
   objUser.AccountDisabled = FALSE
   objuser.mail = objExcel.cells(intRow, 5).Value


   objUser.SetInfo
   intRow = intRow + 1
Loop
objExcel.Quit

Link to comment
Share on other sites


Ok, I'm at work now and I've obviously gotten soemthing wrong with the script.

I get the Following error.

Line 8, Char 4, invalid syntax. Code 800401E4, Source (null)

Not sure what I'm doing wrong here if someone can look at the coding, that would be great.

Link to comment
Share on other sites

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...