Jump to content

Recommended Posts

Posted

First post here so bear with me. I apologize if this has been covered but my search found little helpful posts.

 

Background: Recently moved from Novell Netware to Windows and AD. With Netware, I was able to write an Access file that pulled all users from eDir, compared it to our SIS, and spit out the student users that needed accounts. Then using ICE, I created all accounts. Quick, simple, painless.

 

Currently using Win Server 2008R2 and Exchange 2010

 

Questions: How do you guys handle creating multiple accounts in AD? I can still pull AD users and compare....and get the list of students I need to create accounts for. I've used Ad Infinitum but it only does one context at a time. I've created a VBS script but can't seem to find the correct format for creating certain things (description, office, set password, and set account/password to not expire) and regardless, still have to manually create the home drive. Using any of the above, I have to create the Exchange mailbox manually also.

 

Any advice or suggestions would be greatly appreciated.

 

Thanks for your time.

Posted (edited)

edit: This is on Server 2003R2 - I don't see why it wouldn't work on 2008 though... /edit

 

I export a list of users - here it's initials and their UPN (unique identification number), which I then use excel to calculate their username (which is their initials and a portion of the UPN). Put them all on one line with a "paste special" then save as a CSV. Open the CSV in notepad then put them in this batch file where indicated:

'Create users
for %%a in (list,of,users,separated,by,commas) do dsadd user "CN=%%a,OU=ou2010,OU=ouPupils,OU=ouUsers,DC=cps,DC=local" -display %%a -hmdir \\cpsfilesrv1\users\pupils\ou2010\%%a -hmdrv z: -profile \\cpsfilesrv1\Profiles\pupils\ou09\%%a -loscr pupils2010.bat -pwd 123 -mustchpwd yes -disabled no

'Add them to groups
for %%a in (list,of,users,separated,by,commas) do dsmod group "CN=Domain Users,CN=Users,DC=cps,DC=local" -addmbr "CN=%%a,OU=ou2010,OU=ouPupils,OU=ouUsers,DC=cps,DC=local"

for %%a in (list,of,users,separated,by,commas) do dsmod group "CN=Grppupils2010,OU=ou2010,OU=ouPupils,OU=ouUsers,DC=cps,DC=local" -addmbr "CN=%%a,OU=ou2010,OU=ouPupils,OU=ouUsers,DC=cps,DC=local"

 

Then run it on a DC. You could, of course do it all from the command prompt but with for loops that size I prefer to have the code handy just in case!!

 

PS. Just be careful, those AD locations are, unusually for M$, CaSe SeNsItIve! (that took a bit of troubleshooting a while back I tell you:))

Edited by BatchFile
Posted

Thanks for the input guys. I'll take a look at both suggestions here.

 

Just in case you (or anyone is curious), I have the following VBScript running minus the couple of lines REM out. It pretty much is doing what I want at this point but always looking for better (translate easier!) ways of doing this:

 

Set objExcel = CreateObject("Excel.Application")

Set objWorkbook = objExcel.Workbooks.Open ("C:\Users\djameson\Desktop\ADAccounts\NewADUsers.xls")

objExcel.Application.Visible = True

 

intRow = 2

 

Do Until objExcel.Cells(intRow,1).Value = ""

 

Set objOU = GetObject(objExcel.Cells(intRow,9).Value)

Set objUser = objOU.Create ("User", "cn=" & objExcel.Cells(intRow, 2).Value)

ObjUser.physicalDeliveryOfficeName = objExcel.Cells(intRow,3).Value

objUser.LastName = objExcel.Cells(intRow,4).Value

objUser.FirstName = objExcel.Cells(intRow,5).Value

objUser.DisplayName = objExcel.Cells(intRow,6).Value

objUser.sAMAccountName = objExcel.Cells(intRow,7).Value

objUser.userPrincipalName = objExcel.Cells(intRow,7).Value

objUser.description = objExcel.Cells(intRow,9).Value

objUser.HomeDirectory = objExcel.Cells(intRow,11).Value

objUser.HomeDrive = objExcel.Cells(intRow,12).Value

objUser.userAccountControl = 512

 

objUser.SetInfo

 

objUser.SetPassword objExcel.Cells(intRow,8).Value

objUser.SetInfo

 

' objUser.Put "passwordNeverExpires", true

' objUser.SetInfo

 

intRow = intRow + 1

Loop

 

objExcel.Quit

MsgBox " Users Created!!", ,"ACSD4 AD Usernames"

 

Thanks again for your time.

Posted
You should be able to also do this with a DSadd command, this should allow to to call on a file with the user names already entered

 

Sure, DSAdd will work, if you don't mind being stuck in the 90s.

Posted
PowerShell. That is all.

Thirded. :) Don Jones has some excellent articles and videos on how to provision users in PowerShell...

 

[b]Automate User Provisioning with Windows PowerShell[/b]
[url="http://technet.microsoft.com/en-us/magazine/2009.03.windowspowershell.aspx"]Part 1[/url] ([url="http://technet.microsoft.com/en-us/edge/Video/ff944962"]Video[/url]), [url="http://technet.microsoft.com/en-us/magazine/2009.04.windowspowershell.aspx"]Part 2[/url] ([url="http://technet.microsoft.com/en-us/edge/Video/ff944970"]Video[/url]), [url="http://technet.microsoft.com/en-us/magazine/2009.05.powershell.aspx"]Part 3[/url], [url="http://technet.microsoft.com/en-us/magazine/2009.06.windowspowershell.aspx"]Part 4[/url]

Posted (edited)
AD Infinitum does it for me. Plus it's really good for other AD actions like relocating 1200 Home Folder and TS-Home Folder details or identifying inactivate users by existing login names and last login date. Sure, purists will say that powershell will do this but AD Infinitum does not really need learning or require that you have a programmers orientated brain Edited by mbyrew
Posted
Sure, DSAdd will work, if you don't mind being stuck in the 90s.

 

There is nothing wrong with the DS commands, probably why they are still part of the windows 2008 enterprise admin exam. Powershell is a great tool, but not very easy if you have no scripting background or an overview on the product.

 

We use Primal Script with it's link into Powershell for a lot of our work, but simple AD queries DS still works just as easy and in seconds

  • Thanks 1
Posted
There is nothing wrong with the DS commands, probably why they are still part of the windows 2008 enterprise admin exam. Powershell is a great tool, but not very easy if you have no scripting background or an overview on the product.

 

We use Primal Script with it's link into Powershell for a lot of our work, but simple AD queries DS still works just as easy and in seconds

 

I'm not debating that, but it's like writing a batch script or VBScript file. You just don't do it these days. Just like you don't go out and buy a 1990 model car because there's "nothing wrong with it".

 

Try using DStools to reset the password of every user whose username ends with "aa" but is not in the "Admin" OU.

Posted
I'm not debating that, but it's like writing a batch script or VBScript file. You just don't do it these days. Just like you don't go out and buy a 1990 model car because there's "nothing wrong with it".

 

I've got one of those, too - a 1998 Suzuki Vitara - most of it built with bits from the original design in 1986:cool: It gets me to work and back whatever the weather (untreated roads around here), does the job and I know how it works. It costs pennies to fix because I can get at everything with a socket set, most of it (including an oil change) from under the bonnet - there's that much space!).

 

The point: Like my vitara, DsAdd etc work for me. I understand it, and when I keep the batchfiles™ I can see what I did if I screw up. In much the same way that I don't need a device to buzz my backside when I cross the white line without the indicator on, I've never needed to "to reset the password of every user whose username ends with "aa" but is not in the "Admin" OU." when I do, you'll probably find a thread on here with me asking how to use powershell :)

Posted
I've got one of those, too - a 1998 Suzuki Vitara - most of it built with bits from the original design in 1986:cool: It gets me to work and back whatever the weather (untreated roads around here), does the job and I know how it works. It costs pennies to fix because I can get at everything with a socket set, most of it (including an oil change) from under the bonnet - there's that much space!).

Okay...I said you don't go buy one. Not you don't keep your old one. If your old scripts work fine, use them. It's not my environment, I don't care what you use. However, for a *new* scripter wanting to learn to do things..there is no point recommending he/she use an archaic technology, like there's no point telling him/her that he/she should buy a 1990 automobile.

 

The point: Like my vitara, DsAdd etc work for me. I understand it, and when I keep the batchfiles™ I can see what I did if I screw up. In much the same way that I don't need a device to buzz my backside when I cross the white line without the indicator on, I've never needed to "to reset the password of every user whose username ends with "aa" but is not in the "Admin" OU." when I do, you'll probably find a thread on here with me asking how to use powershell :)
And when you do...I'll be ready. I had to do this very thing on Friday, hence it being fresh in my mind.
Posted

Thanks for all the suggestions and comments. I'll take a look at PowerShell as it appears (from looking at some examples) that it is a combination of some of the things I am using now with some new features.

 

Arthur, thanks for the links. Almost exactly what I want/need to do.

 

Thanks again.

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



×
×
  • Create New...