The first elseif statement that evaluates true is processed, else control passes to the next
elseif statement. It is in this way that the remaining character arrays are tested for the value stored in
$firstchar .
The first elseif statement tests the character array variable $g2k , which if true sets $targetDB to the
databasename of the second mailbox database stored in $mailboxdatabases . The second elseif
statement tests the character array variable $l2p , the third elseif statement tests $q2t , and the last
elseif statement tests $u2z . If all the tests evaluate false, then the else statement at the end of the line
returns the current value stored in $targetDB , which was set to null before entering the if-elseif
statements.
When the if statement or one of the elseif statements evaluates true, the value of $targetDB is set
accordingly and the statement is exited. Control passes to the first command past the else statement,
which returns the value of $targetDB to the command that called the function.
Part IV: Automating Administration
452
# This function determines the target database
function GetDatabase
{
param([string]$lastname)
# Get the first character of the last name value
[string]$firstchar = $lastname.ToCharArray()[0]
# Test the first character against the array values to find the target database
$targetDB = $null
if ($a2f -contains $firstchar)
{
$targetDB = $mailboxdatabases[0].
Pages:
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626