From the course: PowerShell 7 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Control the flow of PowerShell

Control the flow of PowerShell - PowerShell Tutorial

From the course: PowerShell 7 Essential Training

Start my 1-month free trial

Control the flow of PowerShell

- [Illustrator] When building PowerShell scripts, it's important to be able to control the flow, of which functions and commands you wish to execute, and the order that they should happen. So let's consider something. I have a variable with the value 10 inside of it. Now, obviously what I would like to do, is to test that value. This is done by using something like this, and saying if value. Now you notice when I type this, it gives me the two arrows, because it's now waiting for me, to do something with that. The output of that is inside the squarely bracket. So I'm going to say, Write-Host we have a value and enter. And you'll see that returns, because it did a check, for the existence of something in that variable. So fairly straightforward. Now the idea behind the 'if' statement, which is the most common, is to help us structure the information. So if we go back here and type value equals 10, what we can do…

Contents