July 2017
Beginner
222 pages
5h 2m
English
When writing scripts, we have to implement business logic that will shape the process. The if and where statements allow us to define logical conditions. For example, if you would like to compare two numbers, you can use the if and else statements and, based on the comparison, take appropriate action.
Conditional statements are the building blocks of any programming and scripting language.
If a certain condition is true, we can run a block of code. The syntax of an if...else is as follows:
if (<test1>) {<statement list 1>} elseif (<test2>) {<statement list 2>} else {<statement list 3>}
Here's an example:
$a = 6; if( $a -eq 5){ Write-Host "Variable a is equal to 5" } elseif( $a -eq 4){ Write-Host "Variable ...Read now
Unlock full access