name -Database:$user.Database `
-OrganizationalUnit:$user.OrganizationalUnit `
-UserPrincipalName:$user.UserPrincipalName `
-FirstName:$user.FirstName -LastName:$user.LastName `
-Password:$password -ResetPasswordOnNextLogon:$true `
-ErrorVariable err | out-null
If ($err -ne $null)
{
$errorString = ???[ERROR]: Processing user $($user.name) failed with the
following error:???
Out-File $logfile -Append -Inputobject $blankLine, `
$errorString, $err[0], $blankLine
$errorTotal += 1
}
else
{
$outString = ???[SUCCESS]: New mailbox created for $($user.name) on
database: $($user.database)???
Out-File $logFile -Inputobject $outString -append
}
$total += 1
write-progress -Activity ???Processed User: $($user.name)??? -Status ???Progress:??? `
-PercentComplete ($total/$users.count*100)
}
# output the summary
Write-Host -Fore yellow ???`nProcessing complete. $total users were processed with
$errorTotal errors. Please refer to $logfile for more details.`n???
(continued)
Chapter 15: User, Group, and Public Folder Administration
435
Examining the Improved Script
For analysis, this script is broken down into individual segments, each marked with a comment line to
describe what the segment does. The following paragraphs explain how each segment works and are
followed by the specific segment of code they describe.
Pages:
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594