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”
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.