The following code shows the contents of script file simplebulk-newmailbox.ps1 :
# simplebulk-newmailbox.ps1
# Input parameter
param([string]$CSVUpath)
# Prompt for the master password to set on the new mailbox enabled accounts
$password = (Read-Host -AsSecureString ???Enter Password???)
# Read input from the CSV file
$users = (Import-Csv $CSVUpath)
# Create the mailbox enabled accounts
foreach ($user in $users)
{
New-Mailbox -Name:$user.name -Database:$user.Database
-OrganizationalUnit:$user.OrganizationalUnit
-UserPrincipalName:$user.UserPrincipalName -Password:$password
-ResetPasswordOnNextLogon:$true
}
Chapter 15: User, Group, and Public Folder Administration
427
For analysis, this script is broken down into four segments, each marked with a comment line (using the
# character) to describe what the segment does. The following paragraphs explain how each segment
works and are followed by the specific segment of code they describe.
The first code segment uses the param keyword to specify the input parameter value to set on variable
$CSVUpath . This variable holds the path of the CSV file containing the information to be used for
creating the mailbox - enabled user accounts. The $CSVUpath variable is cast as a string data type by the
use of the [string] prefix.
Pages:
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580