
Chapter 15: User, Group, and Public Folder Administration
445
else
{
$thiserror = $errorString + “Distribution Group based on
Department `’$($user.department)`’ could not be found”
out-file $logfile -append -inputobject $blankline, `
$thiserror, $blankline
$noErrors = $false
$errorTotal += 1
}
if ($dgoff = (Get-DistributionGroup | where {$_.name -like `
“*$($user.office)*”}))
{
Add-DistributionGroupMember -Identity:$dgoff `
-Member:$user.name -ErrorVariable err
If ($err -ne $null)
{
$thiserror = $errorString + “addition to Distribution Group
$($dgoff.name) failed with error:”
out-file $logfile -append -inputobject $blankline, `
$thiserror, $err[0], $blankline
$noErrors = $false
$errorTotal += 1
}
}
else
{
$thiserror = $errorString + “Distribution group based on Office
`’$($user.office)`’ could not be found”
out-file $logfile -append -inputobject $blankline, `
$thiserror, $blankline
$noErrors = $false
$errorTotal += 1
}
if ($noErrors)
{
$outstring = “[SUCCESS]: Creation of mailbox enabled account
for user $($user.name) succeeded, with mailbox on database: $($user.database)”
out-file $logfile -inputobject $outstring -append
}
}
}
$total = $total + 1
write-progress -activity “Processed User: $($user.name)” -status “Progress:” `
-percentcomplete ($total/$users.count*100)
}
c15.indd 445c15.indd 445 12/17/07 4:05:24 PM12/17/07 4:05:24 PM