Create Bulk Mailbox Users from CSV using Powershell

We can use the Exchange Powershell cmdlet New-Mailbox to create mailbox AD user.In this article, I am going write powershell script create bulk exchange mailbox users from csv and enable mailboxes for existing AD users.

Before proceed, run the following command to enable Exchange cmdlets if you are working with Powershell console instead of Exchange Management Shell.

Add-PSSnapin *Exchange*

The following command creates the Active Directory user “Tim Brensan” in the TestOU, with a mailbox on the “TestDBStore” database and set the “Change Password at Next Logon” flag as true.

New-Mailbox -UserPrincipalName [email protected] -Alias 'TimBrensan' -Database 'TestDBStore' -Name TimBrensan –OrganizationalUnit TestOU -Password (ConvertTo-SecureString 'MyP@ssw0rd1' -AsPlainText -Force) -FirstName Tim -LastName Brensan -DisplayName 'Tim Brensan' -ResetPasswordOnNextLogon $True

Create Bulk Exchange Mailbox Users from CSV

1. Consider the CSV file MailboxUsers.csv which contains set of new exchange mailboxes to create with the attributes name, alias, userPrincipalName, database, firstName, lastName, displayName and ParentOU.

Create Bulk Mailbox AD Users from CSV file using Powershell

2. Copy the below Powershell script and paste in Notepad file.
3. Change the MailboxUsers.csv file path with your own csv file path.
4. SaveAs the Notepad file with the extension .ps1 like Create-Bulk-Mailbox-AD-Users.ps1

Import-Csv "C:\ScriptsMailboxUsers.csv" | ForEach-Object {
New-Mailbox -UserPrincipalName $_.'userPrincipalName' -Alias $_.'alias' -Database $_.'database' -Name $_.'name' –OrganizationalUnit $_.'ParentOU' -Password (ConvertTo-SecureString 'MyPassword123' -AsPlainText -Force) -FirstName $_.'firstName' -LastName $_.'lastName' -DisplayName $_.'displayName' -ResetPasswordOnNextLogon $True }

5. Now run the file Create-Bulk-Mailbox-AD-Users.ps1 in powershell to create bulk Active Directory users and Mailboxes from CSV file.

Create Bulk Mailboxes for existing AD Users

1. Consider the CSV file ADUsers.CSV which contains set of existing AD users that we want to enable mailbox with the attributes name, alias and database.

Create Mailbox for Bulk AD Users from CSV using Powershell

2. Copy the below Powershell script and paste in Notepad file.
3. Change the ADUsers.CSV file path with your own csv file path.
4. SaveAs the Notepad file with the extension .ps1 like Create-Mailbox-for-Bulk-AD-Users.ps1


Import-Csv "C:\ScriptsADUsers.csv" | ForEach-Object {
Enable-Mailbox -Identity:$_.'name' -Alias:$_.'alias' -Database:$_.'database'
}

5. Now run the file Create-Mailbox-for-Bulk-AD-Users.ps1 in Powershell to create Bulk Active Directory users and Mailboxes from CSV file.

Advertisement

1 thought on “Create Bulk Mailbox Users from CSV using Powershell”

  1. Hi,

    If we also need to set the PrimaryEmailAddress field whereas we have multiple domain hosted in single exchange server, then can you please share the syntax to do that.

    Regards,
    Sonu Chauhan

    Reply

Leave a Comment