Prev | Current Page 585 | Next

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

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

To make these tests, if
statements are used. The syntax of an if statement is quite simple:
if ( < conditional test > ) { < code block > }
Basically, an if statement works like this: If the < conditional test > evaluates true , execute the
contents of the < code block > . If the < conditional test > evaluates false , skip the < code block >
and go to the next command.
The first if statement tests the value stored in $CSVUpath to see if it is equal to null, which would
mean the user forgot to supply an input value when the script was run. If that is so, the conditional test
evaluates to true, and the code block is executed.
If the script block runs, the $notValidPath variable is set to $true . The Write-Host cmdlet is used to
display a text message advising the user to enter the full path to a CSV file. The fore parameter is used
to change the text color to yellow so it stands out as a warning. The text string value includes a special
character combination of the grave accent escape character and the letter n ( `n ) that causes the shell to
display the text that follows at the start of a new line. This ensures that the message is displayed on a line
by itself for maximum readability.
The return command is used to return the value stored in $notValidPath to the command that called
the ValidatePath function.


Pages:
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
ciekawe opony goodyear karta kredytowa millenium House Extension London zakłady bukmacherskie