Powershell Task of the Day – Bulk Email Account Creation

A new office requires a large number of email accounts to be created. Fortunately, the users already had Active Directory accounts and they were in the same organisational unit. I used the following Powershell command to create the users:

get-user -OrganizationalUnit "domain.local/Company/State/OfficeLocation/Department/Team" | `
where-object {$_.RecipientType -eq "User"} | `
Enable-Mailbox -database "EXCH01StorageGroup1Database1"

Line 1 gets the users in the specified organisation unit, while line 2 narrows the results to just User objects. Line 3 performs the actual mailbox creation. 86 users were created with effectively one line of code.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bitnami