locked
Bulk EX2010 Mailbox Creation via CSV for Existing AD Accounts RRS feed

  • Question

  • I have 1200 AD accounts in different domains in the same Forest, which now require full Exchange 2010 mailboxes.  I have these users listed in a CSV - does anyone have a Powershell script that will take the existing AD accounts and bulk enable them with  mailboxes?

     

    Any assistance greatly appreciated.
    Monday, June 28, 2010 8:01 PM

Answers

  • The CSV file needs headers in the first line.  If your first line has "UserID" looks like this:
     
    DisplayName,UserID
     
    $Mailboxes = Import-CSV filename.csv
    ForEach ($Mailbox In $Mailboxes) { New-Mailbox -Name $Mailbox.DisplayName -DisplayName $Mailbox.DisplayName -SamAccountName $Mailbox.UserID }
     
    You'll want to supply additional fields in the CSV file or literally to fill out all the other parameters in the New-Mailbox command, like the mailbox database, password, etc. but this example should show you how it's done.
    --
    Ed Crowley MVP
    "There are seldom good technological solutions to behavioral problems."
    .
    "Stuabroad" wrote in message news:ec95de20-3aaf-45ff-930c-137e4e408cc4...

    I have 1200 AD accounts in different domains in the same Forest, which now require full Exchange 2010 mailboxes.  I have these users listed in a CSV - does anyone have a Powershell script that will take the existing AD accounts and bulk enable them with  mailboxes?

     

    Any assistance greatly appreciated.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    • Marked as answer by MbxMan Tuesday, June 29, 2010 12:36 AM
    Monday, June 28, 2010 8:55 PM
  • You can always tell a cool thread, when you come back to that same thread three  years later asking the same question but for a different project!  This time it's Exchange 2013 :)  
    • Marked as answer by MbxMan Tuesday, August 20, 2013 9:31 PM
    Tuesday, August 20, 2013 4:55 PM

All replies

  • The CSV file needs headers in the first line.  If your first line has "UserID" looks like this:
     
    DisplayName,UserID
     
    $Mailboxes = Import-CSV filename.csv
    ForEach ($Mailbox In $Mailboxes) { New-Mailbox -Name $Mailbox.DisplayName -DisplayName $Mailbox.DisplayName -SamAccountName $Mailbox.UserID }
     
    You'll want to supply additional fields in the CSV file or literally to fill out all the other parameters in the New-Mailbox command, like the mailbox database, password, etc. but this example should show you how it's done.
    --
    Ed Crowley MVP
    "There are seldom good technological solutions to behavioral problems."
    .
    "Stuabroad" wrote in message news:ec95de20-3aaf-45ff-930c-137e4e408cc4...

    I have 1200 AD accounts in different domains in the same Forest, which now require full Exchange 2010 mailboxes.  I have these users listed in a CSV - does anyone have a Powershell script that will take the existing AD accounts and bulk enable them with  mailboxes?

     

    Any assistance greatly appreciated.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
    • Marked as answer by MbxMan Tuesday, June 29, 2010 12:36 AM
    Monday, June 28, 2010 8:55 PM
  • Thanks will give that a try with the extra parameters :)
    Monday, June 28, 2010 10:43 PM
  • Did the script work for you ???
    Sunday, August 1, 2010 3:46 PM
  • Ok - I just spent half the day searching for this very topic.  However, every site gives you the code for CREATING NEW users AND the mailboxes.  I already have the users and just want to bulk add mailboxes via CSV file for these users.  And here's how it works:

    First - Create the .csv file in notepad (Don't put a line between each entry, as below)

    Identity,Database

    April Stewart,Mailbox Database

    Jeff Ford,Mailbox Database

    Tony Krijnen,Mailbox Database

    Note: "Mailbox Database" is the name of my Email DataBase (yours might be different)

    SAVE THIS AS C:\NEWBIE.CSV

    NEXT Create the script

    Open a new notepad file

    Type the following: AGAIN DON'T PUT A SPACE BETWEEN THE LINES - AND IT'S NOT CASE SENSITIVE

    $mailbox=import-csv C:\NEWBIE.CSV

    ForEach ($mailbox in $mailbox) {Enable-Mailbox -Identity $Mailbox.Identity -Database $Mailbox.Database}

    SAVE THIS AS C:\ENABLEBOX.PS1

    NEXT: Run the Script

    Go to Exchange Management Shell

    You can change the directory to the root by typing cd\ then hit Enter (NOTE: If you just typed the words "then hit Enter" you do not belong working on servers)

    Then type: ./enablebox.ps1

    Press enter and watch the magic unfold

    Jim Manning MBA, MIS., CNE, MCA

     

    Monday, March 21, 2011 8:56 PM
  • Just in case you want to enable archive for all users in the csv add this to the above script. Add <| Enable-Mailbox –Archive -ArchiveDatabase "<enter archive db name here>"}> Shown below in its entirety. 

    $mailbox=import-csv C:\<filename>.CSV
    ForEach ($mailbox in $mailbox) {Enable-Mailbox -Identity $Mailbox.Identity -Database $Mailbox.Database | Enable-Mailbox –Archive -ArchiveDatabase "<enter archive db name here>"}

    Tuesday, November 22, 2011 7:42 PM
  • HI Huang N. Lo

    very helpful actually we are looking for the same,we have 300 active directory users,we want to enable mail box in Exchange 2010,my mail database name is DB1,can please explain little.

    Thursday, January 26, 2012 5:02 AM
  • You can always tell a cool thread, when you come back to that same thread three  years later asking the same question but for a different project!  This time it's Exchange 2013 :)  
    • Marked as answer by MbxMan Tuesday, August 20, 2013 9:31 PM
    Tuesday, August 20, 2013 4:55 PM
  • I'm migrating a customer from their hosting environment (Ex2010) to on-premise (Ex2013).

    I need to recreate from scratch the target infrastructure. Fun.

     I have a CSV which contains data for the following lines.  

    SamAccountName,PrimarySMTPAddress,EmailAddresses,FirstName,LastName,HomePhone,MobilePhone,Phone,Company,Title,Department,Office,UserPrincipalName,ForwardingSMTPAddress,FullAccess,SendAs,SendOnBehalf


    How can i CREATE new mailboxes for these people with this data (or as close as possible) in order to populate the GAL etc?  They already have EXISTING AD accounts.

    Any help greatly appreciated.

    Wednesday, August 21, 2013 9:08 PM
  • Follow the examples above in this thread.  Sorry that I don't have the time to write and debug a script for you.

    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

    Sunday, August 25, 2013 4:01 AM
  • I have tested it and confirm its working. Following Jim suggestion and modify the setting as bellow.

    1. Use your same csv file and just add one more column for Database for each user (If you are using different database name for each users).

    2. and modify Jim script as below:

    $mailbox=import-csv C:\yourfile.CSV

    ForEach ($mailbox in $mailbox) {Enable-Mailbox -Identity $Mailbox.SamAccountName -Database $Mailbox.Database}

    3. Save the script and run it.

    Thanks

    Shambhu

    Thursday, November 28, 2013 9:37 PM