At this point all
processing for the current user is complete and control passes back to the foreach loop to process the
next user.
Chapter 15: User, Group, and Public Folder Administration
447
If ($err -ne $null)
{
$errorString += ???property assignment failed with error:???
Out-File $logFile -Append -Inputobject $blankLine, $errorString, `
$err[0], $blankLine
$errorTotal += 1
}
If user attributes are successfully set, the if statement is skipped and the else block that follows it
executes instead. It is in this else block that the user attributes are evaluated and the account is added to
the corresponding Distribution Groups. There are two separate Distribution Group add operations in
this block. Each operation has a chance to fail so there is a potential to log two separate error messages.
The $noErrors variable is used to keep track of these individual failures. An overall success message is
written to the log only when $noErrors is still true when all processing for the current user is complete.
else
{
$noErrors = $true
The next if statement is used to add the user to a Distribution Group based on Department. The
condition block for this if statement serves two purposes. First, the $dgdept variable is set with the
object returned by Get-DistributionGroup where the name is similar to the user ??™ s Department
attribute value.
Pages:
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617