How to Import Users via CSV in Exchange 2010

exchange 2007, Exchange 2010

Create an csv file with the necessary information across the top row of the file as such:


The top row is going to coordinate with the S_.value that you are going to use in the following Exchange Shell command:

Import-CSV “C:Mailboxes.csv” | foreach {new-mailbox –Name $ –Alias $_.alias –UserPrincipalName $_.userprincipalname –Database $_.Database –OrganizationalUnit $_.organizationalunit –password (ConvertTo-SecureString $_.password –AsPlainText –force)}


And you should see the mailbox’s created below:


That’s it.  You can see how the values map with their respective column names.  You can add as many users as you want, and change it so they go to different database’s.

You can even create an automated job to export from your production servers, and them import them to your DEV Exchange Servers for testing. 


  1. Lenny

    Curious if you could add the archive database is this as well ? Also is the pw option the admins pw or does that force the reset of the users pw ?

    1. ponzekap2 Post author


      Yes, you can add any values of creating the users into the spreadsheet. And the PW that we set creates the users password, but you can add options to force them to reset it after their initial log in.

  2. Lenny

    Is this to create a new user in AD and create a mailbox as well ? If I had an AD user and just wanted to create a mailbox I would use the enable PS command correct ?

  3. Lenny

    This is my script but I keep getting

    Import-CSV “c:test.csv” | foreach {enable-mailbox –Identity $_.Identity –DisplayName $_.Displayname -Alias $_.Alias
    –Database $_.Database -Archive $_.Archive -Archivedatabase $_.ArchiveDatabase}

    Parameter set cannot be resolved using the specified named parameters.
    + CategoryInfo : InvalidArgument: (:) [Enable-Mailbox], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Enable-Mailbox

    My CSV File

    Test Test4,ttest4,ttest4@,DB1,$true,Archive Database
    Test Test5,ttest5,ttest5@,DB1,$true,Archive Database
    Test Test6,ttest6,ttest6@,DB1,$true,Archive Database
    Test Test7,ttest7,ttest7@,DB1,$true,Archive Database

    1. Lenny

      yeah the domain name is after user@domainname for some reason when I posted it it removed “domainname”.

  4. Lenny

    Got it.

    Import-CSV “c:test.csv” | foreach {enable-mailbox –Identity $_.Identity –DisplayName $_.Displayname -PrimarySmtpAddress $_.SMTP –Database $_.Database | Enable-Mailbox –Archive -ArchiveDatabase “Archive Database” | Set-Mailbox -EmailAddressPolicyEnabled:$true}

    CSV File:

    Test Test4,Test Test4,ttest4@domainname,DB1
    Test Test5,Test Test5,ttest5@domainname,DB1
    Test Test6,Test Test6,ttest6@domainname,DB1
    Test Test7,Test Test7,ttest7@domainname,DB1

  5. an nguyen

    can you show me all parameters of this command?
    such as:
    do they exist in import-csv?

  6. Neilus

    Import-CSV “user.csv” | ForEach-Object { New-Mailbox -Name $_.”dname” -FirstName $_.”fname” -LastName $_.”lname” -UserPrincipalName $_.”aname”+@Domain.local -SamAccountName $_.”aname” -Alias $_.”alias” -Password (ConvertTo-SecureString $_.password -AsPlainText -Force) -ResetPasswordOnNextLogon $false -OrganizationalUnit “Domain.local/OU/Users” -Database “Mailbox Database” -RetentionPolicy “Default Archive and Retention Policy” -ActiveSyncMailboxPolicy “Default”|Set-User -Department $_.”department” -Title $_.”title” -Company $_.”company”}



  7. mazze

    Thanx! Great job! what is the parameter for “PasswordNeverExpires” ???

  8. begsis

    Could you check my error ??
    Import-CSV “C:users.csv” | foreach {new-mailbox –fName $_.fname –lname $_.lname –Alias $_.alias –PrimarySmtpAddress $_.smtp –Database $_.Database –OrganizationalUnit $_.organizationalUnit –password (ConvertTo-SecureString $_.password –AsPlainText –force)}
    + CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSe
    CSV File : fname lname alias smtp database organizationalUnit password
    Thanks in advance !

  9. Darren Greer

    I just wanted to thank you for posting this. It made setting my Primary SMTP Addresses a snap.

Comments are closed.