The New-Mailbox
cmdlet creates each mailbox - enabled user account, and an if statement is used to test if the account was
successfully created. It is after this point that the new lines of code are introduced.
In short, the new code starts by setting the Department and Office attribute values on the new user
account. If there is a failure when setting the attributes, an error message is written to the log and
processing for that user is complete, else processing continues. If there is a Distribution Group with a
name that matches the Department attribute value, the current user is added to that group, else an error
message is written to the log and processing continues.
This operation is repeated for a Distribution Group with a name that matches the Office attribute value.
If there is an error adding the user to either group, an error message is written to the log accordingly. If
the user is successfully added to both Distribution Groups, a success message is written to the log and
processing for that user is complete.
The following paragraphs examine in detail the code segments used to accomplish this functionality
followed by the specific segment of code they describe.
All of the new code is encapsulated in an else statement that executes only if the New-Mailbox
operation is successful.
Pages:
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615