Prev | Current Page 587 | Next

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

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


If the conditional test evaluates to true (the file was not found), the code block is executed. The
$notValidPath variable is set to $true and the Write-Host cmdlet is used to display a text message
advising the user to check the file path entered and try again. The value stored in $notValidPath is
then returned to the command that called the ValidatePath function and processing of the function
is complete.
if (!(Test-Path -PathType:leaf $CSVUPath))
{
$notValidPath = $true
Write-Host -fore yellow ???`nThe file path entered is invalid. Please check
the file path and try again.`n???
return $notValidPath
}
The last command in the function executes only when both if statements have evaluated false . The
initial value stored in $notValidPath would not have been changed because neither if statement
executed, so the value returned to the command that called the function would be $false .
return $notValidPath
The next code segment uses an if statement to evaluate the result of calling the ValidatePath function.
If the result is true, which would be the case if one of the tests in ValidatePath failed, then the code
block is executed. The only command in the code block is exit , which causes Windows PowerShell to
stop processing and exit the script immediately.
If the result of calling the ValidatePath function is false, which would be the case if both of the tests in
ValidatePath passed, then the code block is skipped and the script continues to execute.


Pages:
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
Margo Marquess Łona teksty pl mapa Limp Bizkit