The $errorString variable is used to store a string value that will be used as
the basis for all error messages written to the log file. When an error is generated, additional text will be
concatenated to the end of $errorString to complete the error message.
else
{
$errorString = ???[ERROR]: Creation of mailbox enabled account for user
$($user.name) succeeded, but ???
Because the New-Mailbox cmdlet does not provide for setting non - mail - related attributes when creating
a user account, the Set-User cmdlet is used in a separate command to set the Department and Office
properties. The values used are taken from the data read from the same CSV file that supplied the values
used to create the account with New-Mailbox .
Set-User -Identity:$user.name -Department:$user.department `
-Office:$user.Office -ErrorVariable err
The if block following Set-User checks to see if there were any errors when setting the attribute
values. Neither attribute is validated when they are set, so it is not likely that setting these values would
cause an error. However, should there be an error generated by Set-User , there should be no attempt to
add the user account to a Distribution Group because the attributes that determine group membership
are compromised.
The error is captured in the $err variable and is used along with the text stored in the $errorString
variable plus the text string shown to construct the error message written to the log file.
Pages:
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616