Exchange 2016 - Bulk create mailbox from csv

Ivan
Ivan used Ask the Experts™
on
Hello,

does anyone have an example of both  .csv and PS command, to bulk import users?
I know that I can do it via Get-User -OrganizationalUnit "domain.com/Some OU" | Enable-Mailbox, but not all users in each OU should get mailbox, so it's a bit of a problem.

Regards,
Ivan.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Tahir QureshiSystem Analyst
Commented:
That will do for you

Add-PSSnapin *Exchange*
Import-Csv "C:\Scripts\MailboxUsers.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 }
System Engineer
Commented:
Hi,

new-mailbox is used to create both AD account and mailbox.

Anyway, found the solution.
1. create .csv with field Identity, and below it list of users in username format
2. run command: Import-Csv .\Users.csv | foreach {Get-user -Identity $_.Alias | Enable-Mailbox}

Thank you for help.

Regards,
Ivan.
IvanSystem Engineer

Author

Commented:
I found my own solution.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial