Submitted By: Adam Smith

Finds the Microsoft Exchange 2007 database with the fewest mailboxes, then uses information retrieved from a text file to enable mailboxes in that database. Thanks to Nick Smith ( for the portion of the script that finds the database.

#Change "ServerName" and Path to filename

$DB = (Get-Mailbox -server "ServerName" -ResultSize:Unlimited | Group-Object -Property:Database | 
Sort-Object -Property:Count | Select-Object -Property:Name)[0]

Import-Csv c:\scripts\newMBX.csv | foreach {enable-mailbox -Identity $_.alias -Alias $_.alias -Database $DB.Name}