One of the nice features in Exchange Server
is creating multiple users from one command only. This can be done by
creating *.csv file and executing PowerShell command. In the below
section, we will know the steps required to create multiple mailboxes:
1. First create a *.csv file called recipietns.csv on the root drive (C:\) and type the column names on the first row of this file. These columns will be the Alias, the Name and UPN.
2. Once you enter the user information, next step is to create a variable in the Exchange
Management Shell that will store the first password for all of the user
accounts in the recipients.csv file. To do so, type the following:
$Password = Read-Host Type the default password for the new accounts: -AsSecureString
$Password = Read-Host Type the default password for the new accounts: -AsSecureString
3.
Next we will run two different cmdlets by using a pipe to create the
new users using the *.csv file. Below is the syntax of cmdlet:
Import-Csv recipients.csv | foreach { New-Mailbox “alias $_.Alias “name $_.Name “UserPrincipalName $_.UPN “Database mailbox database “OrganizationalUnit Users “Password $Password “ResetPasswordOnNextLogon:$true
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.
4. Open the Exchange Management Console to check if users are created or not.
No comments:
Post a Comment