Using *.csv files to create mailboxes
http://www.msexchange.org/tutorials/Managing-mailboxes-Exchange-Server-2007-Part1.html
Another interesting feature is the one that lets an administrator create several users from a *.csv file. In the following section, we will review a step by step procedure to create mailboxes:
- First of all, we will have to create a *.csv file called recipients.csv on the root drive (C:\) and we will type the column names for the file in the first line. Those columns will be the Alias, the Name and UPN. in the following lines we will complete the user information (Figure 09).
Figure 09: Creating a csv file to be used in the creation of users through Exchange Management Shell
- Once the user information is complete, we will have to create a variable in the Exchange Management Shell that will keep the initial password for all of the accounts on the recipients.csv file. To do so, we will type the following:
$Password = Read-Host "Type the default password for the new accounts:" -AsSecureString
Figure 10: Creating a variable to keep the initial password on the new accounts
- In the following step, we will run two cmdlets using a pipe to create the new users using the *.csv file. This is the syntax of our cmdlet:
Import-Csv recipients.csv | foreach { New-Mailbox –alias $_.Alias –name $_.Name –UserPrincipalName $_.UPN –Database "mailbox database" –OrganizationalUnit Users –Password $Password
–ResetPasswordOnNextLogon:$true
The options are explained here:
- $_.<Name>: This is the name of each column of the recipients.csv file.
- Foreach: For each line of the file; Note: the first line is the header.
- $Password: variable that we just typed in the previous step.
- -ResetPasswordOnNextLogon:$true: If we set this parameter to true, all the users will have to change their password on the first logon.
Figure 11: Creating users through a *.csv file
- To check if the users were created, we will go to the Exchange Management Console (Figure 12).
Figure 12: The new users created through the csv file