Making AD accounts in an OU "mail-enabled" using powershell

If you have a number of users in an OU that are not mail-enabled. You can use the following command to look for all users in a specific OU and then make them mail-enabled:

Get-User -OrganizationalUnit "pnlab.com/pnlab/users/needmailenabled" | Enable-Mailbox -Database "PNLAB storage group\mailbox database"

Explaination:
Get-User -OrganizationalUnit "pnlab.com/pnlab/users/needmailenabled" | lists all users in the pnlab.com domain, pnlab/users/needmailenabled OU and then pipe the results (line by line) into the next command

Enable-Mailbox -Database "PNLAB storage group\mailbox database" This command takes the output of the last command (Get-User) and mail-enable the AD account puting them into the "PNLAB storage group" storage group and "mailbox database" database.

The great thing about this is if there are any user(s) in that OU that are already mail-enabled, powershell will give you an error stating those users already mail-enabled and continue on to process the rest of the users.

 del.icio.us  Stumbleupon  Technorati  Digg 

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments
  • No comments exist for this entry.
Leave a comment

Submitted comments will be subject to moderation before being displayed.

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.