Notice that the error messages contain no information about the object being
processed when failures occur. That means an administrator would have to search through the contents
of a CSV file to discover the users that have failed creation.
The script also does a poor job of giving the administrator feedback when other errors occur. For
example, when an invalid CSV file path is specified, the standard error message for the underlying
command is displayed. In most cases this feedback is more cryptic than necessary and does not always
imply a corrective action to take.
Part IV: Automating Administration
432
The next section explores an improved version of the simplebulk-newmailbox.ps1 script that
incorporates some advanced techniques to address the shortcomings of the simple script and provide a
more complete solution.
The Improved Script
The script bulk-newmailbox.v1.ps1 includes several improvements that make it a more robust
solution for creating new mailbox - enabled user accounts:
??‘ Comments have been added to the header of the script to include Synopsis, Usage, and Example
information. This is always good practice, especially when sharing scripts with other
administrators.
??‘ Error checking has been added to validate the path and format of the CSV file. The user is
prompted to take specific corrective action if there is not an existing file in the path given, or if
the file is not a properly formatted CSV file.
Pages:
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590