Tuesday, August 20, 2013

Bulk creating and removing mailboxes

To create users in Exchange 2013, when they already exist in AD this script is useful.

foreach ($user in get-content users.txt)
Enable-mailbox –identity mydomain\$user –database mailboxdatabase1
write-host "$user is processed."

Users are stored in users.txt

To only remove mailbox, but not the AD-user from exchange. This is useful when needing to redo import if something didn’t land where it should.

foreach ($user in get-content DeleteUsers.txt)
disable-mailbox –identity mydomain\$user -confirm:$false
write-host "$user is processed."

Users are stored in DeleteUsers.txt

Each line contains one username.



No comments: