Bulk creation of AD user accounts with Exchange 2010 sp1 supplied script

Status
Not open for further replies.
C

Crustbusta



I've believe that I have recently read somewhere that Exchange 2010 sp1 comes supplied with a script or similar to allow for the creation of user account objects in AD. I've now how a need to use this but can't for the life of me remember the details. Can someone please put me out of my misery.

Many thanks in advance
 
B

busbar

C

Crustbusta



Thanks I appreciate the information however I know I read something somewhere and that's bugging me so I was just wondering if anyone else had read the same thing.

Anybody ??? :)
 
S

Steve Goodman



No there is no special script in SP1 for this. New-Mailbox and New-MailUser do this though (with Exchange attributes populated) and it's easy to use something like a CSV file as input.

What are you trying to achieve? Someone here can probably help with a small script.

Steve

Steve Goodman
Check out my Blog for more Exchange info or find me on Twitter
 
C

Crustbusta



Hi Steve,

Thanks for the info.

I'm just trying to create a couple of hundred of AD user accounts quickly using the following attributes contained in a CSV file.

Pete ....

GivenName Surname SamAccountName DisplayName

Password
 
S

Steve Goodman



Hiya,

I'd also add a UserPrincipalName value to the CSV file, then something like:

This to test (with the WhatIf parameter)

Import-CSV .\input.csv | %{ New-Mailbox $_.SamAccountName -DisplayName $_.DisplayName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -FirstName $_.GivenName -LastName %_.Surname -Password (Convertto-SecureString -Force -AsPlainText $_.Password) -WhatIf}

Then to do it (taking off the WhatIf parameter)

Import-CSV .\input.csv | %{ New-Mailbox $_.SamAccountName -DisplayName $_.DisplayName -SamAccountName $_.SamAccountName -UserPrincipalName $_.UserPrincipalName -FirstName $_.GivenName -LastName %_.Surname -Password (Convertto-SecureString -Force -AsPlainText $_.Password)}

You can also add extra parameters to the New-Mailbox before the last }, such as Organizational Unit, Database etc, policies etc. Check out Get-Help New-Mailbox -Detailed for more info.
Steve

Steve Goodman
Check out my Blog for more Exchange info or find me on Twitter
 
B

Brian Day MCITP



You want to use Import-CSV piped into New-Mailbox. There are certain parameters which are required in order to make a new mailbox and they aren't all in your list. I've used the required list below.

For example if the first line of your CSV file was;

GivenName,SurName,SamAccountName,DisplayName,UserPrincipalName,Name,Password

...those values would be used as properties for each object (line) in the CSV file you import.

Here is an example you can try in your lab and massage as necessary.

First import the values to a variabl with something like; $MailboxesToMake = $Import-CSV c:\myfile.csv

Then you run something like this...

$MailboxesToMake | foreach {New-Mailbox -Displayname $_.DisplayName -Firstname $_.GivenName -LastName $_.SurName -SamAccountName $_.SamAccountName -Name $_.Name -Password $_.Password}

That pipes the objects from $MailboxesToMake to a foreach loop which then executes the code block inside the {} one time per object. The $_ notation in PowerShell is the 'current object' you are working with. You'll notice there is no -Database parameter up above, so Exchange would randomly choose a database in the local AD site to create the mailbox in. If you wanted to choose the DB, put another column in the CSV named "Database" in Row 1, then add -Database $_.Database to the example PowerShell line. This also doesn't specify the OU, which is something else you could add or just move them later.

Import-CSV: http://technet.microsoft.com/en-us/library/dd347665.aspx

New-Mailbox: http://technet.microsoft.com/en-us/library/aa997663.aspx

 
B

busbar



adding to Brian,

please check this link for further details:

http://www.exchangepedia.com/blog/2006/11/exchange-server-2007-bulk-creation-of.html

Regards, Mahmoud Magdy Watch Arabic Level 300 Videos about Exchange 2010 here: http://vimeo.com/user3271816 Read pretty advanced Exchange stuff I post here: http://www.enowconsulting.com/ese/blog.asp, follow my blog: http://autodiscover.wordpress.com , corp blog: http://ingazat.wordpress.com and if you Liked my post please mark it as helpful and accept it as an answer
 
Status
Not open for further replies.
Top