To begin, you can use the PowerShell script found on Exchange MVP Andy Grogan's site to reach out for an editable...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
.csv file and create 300 user accounts. After going to Andy's site, download the Create-Users.exe file to receive an editable PS1 file, which is the PowerShell script, as well as a .csv file that includes the login password.
To run the script, open PowerShell, navigate to where you placed the script and type .\CreateUsersFromCSV.ps1. This will open a dialog box, allowing you to locate the .csv file. Once you've selected the .csv file, it will create 300 users and place those users into an organizational unit (OU) called ExchangeUsers.
Note: You can edit the script so that it uses a different name; however, once users are created, you can either move them to another OU or change the name of the ExchangeUsers OU.
Bulk mailbox import
Once you've created 300 new users, you'll need to make them into mailboxes. Exchange expert Bharat Suneja walks you through the process of creating bulk mailboxes on his blog. The Exchange Management Console's New Mailbox wizard creates mailboxes for existing users; the wizard lets you select more than one user.
Once you create mailboxes, only existing users without mailboxes will be visible in the wizard. No additional information is provided and there is no filtering mechanism. This is where PowerShell comes into play.
Open the Exchange Management Shell . To import users from a specific OU type Get-User –OrganizationalUnit <OU Name>. Keep in mind, though, that this will return all of the users in that OU, some of which may already have mailboxes. To narrow down the selection of users, request for RecipientType and say it's equivalent to User instead of UserMailbox.
For example, if you wanted to locate all users in the Sales OU who do not have mailboxes for their accounts, type the following command:
Get-User –OrganizationalUnit Sales | Where-Object [$_.RecipientType –eq "User"}
To enable mailboxes for those users, add the following script to the end of the command:
Enable-Mailbox –Database "<Name of Database>"
Note: Because Exchange Server 2007 uses storage groups, you would need to use the following command for that version:
Enable-Mailbox -Database "Name of Storage Group\Name of Database"
Next, assume that lab users are located in the ExchangeUsers OU and you want their mailboxes to reside in a database called MBDatabase. To do so, type the full command:
Get-User –OrganizationalUnit ExchangeUsers | Where-Object [$_.RecipientType –eq "User"} | Enable-Mailbox –Database "MBDatabase"
You have now set up a lab with hundreds of users -- with mailboxes -- in just a couple of minutes.
|ABOUT THE AUTHOR:|
J. Peter Bruzzese (Triple-MCSE, MCT, MCITP: Messaging) has been working with Exchange Server for more than 10 years. His latest book Exchange 2007 SP1 How-To published by Sam's Publishing was released in January 2009. He speaks about Exchange at various conferences including TechMentor. His website www.exclusivelyexchange.com includes 150 free training videos on Microsoft Exchange. He is currently working with Train Signal to provide an epic Exchange 2010 Training course that is due out this June.