An else statement is used as a way of executing an
alternate command when the conditional test of an if statement evaluates false. The else statement has
no conditional test of its own and instead relies on the result of the preceding if statement. Therefore the
else statement code block only executes when New-Mailbox successfully creates a mailbox - enabled
user account.
The $outstring variable is used to store a text message string that includes the name of the user that
was successfully processed by New-Mailbox . This variable is used by Out-File to append the message
to the bulk-newmailbox.log file.
else
{
$outString = ???[SUCCESS]: New mailbox created for $($user.name) on
database: $($user.database)???
Out-File $logFile -Inputobject $outString -append
}
To track the total number of users processed, the $total variable is incremented by 1 each time the
foreach loop executes. This value will be used later in the summary display to report the total number
of users processed.
$total += 1
The last command in the foreach loop is the Write-Progress cmdlet, which is used to generate a
progress bar display on the console screen as the foreach loop executes. The progress bar is made up of
three visible elements: the activity label, the status label, and the progress indicator.
Pages:
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606