Prev | Current Page 622 | Next

Joezer Cookey-Gam, Brendan Keane, Jeffrey Rosen, and Jonathan Runyon

"Professional Windows PowerShell for Exchange Server 2007 Service Pack 1"


#This function validates the user specified
function validateUser
{
$notValidUser = $false
The next code segment uses an if statement to test if a value was passed at the command line when the
script was run. If $user is null, $notValid is set to $true and an error message is displayed on the
screen to instruct the administrator to supply a valid user account. The value of $notValidUser is
returned to the command that called validateUser and all processing for the function is complete.
if ($user -eq ??????)
{
$notValidUser = $true
Write-Host -fore yellow ???`nYou must enter a mailbox enabled user account as
input to this script.`n???
return $notValidUser
}
Part IV: Automating Administration
458
The next code segment uses another if statement to test if a value held in $userMB holds an object that
is the result of running Get-Mailbox with $user as input. This command is used later in the script
before the function is called, so should hold a value when tested at this point. Supplying a valid mailbox -
enabled user to Get-Mailbox would result in populating $userMB with a mailbox user object that
evaluates as true when tested. If the account is not mailbox - enabled, or cannot be found in Active
Directory, then $userMB is false and the conditional test would ultimately result in true thanks to the
NOT operator.


Pages:
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
perfumy fm Anteny satelitarne apartamenty przy plaży online loan for bad credit rekuperatory