From the course: PowerShell: Automating IT Administration

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Looping constructs for data manipulation

Looping constructs for data manipulation - PowerShell Tutorial

From the course: PowerShell: Automating IT Administration

Looping constructs for data manipulation

- [Instructor] Now, another function that's really important inside PowerShell is the ability for you to loop content. Now, in one of our previous examples, we touched on it by using a foreach statement to be able to iterate through the data that we imported and we didn't focus on it too much. So I wanted to go back and talk about looping constructs. So first off, our very first one is for. It's a for loop. This is basically where we iterate until we basically tell it to do something. So if we take this line six, for example, here, we're creating a variable called $i and giving it a start number of one, which means it will begin there and then get to a specific number that we tell it. So we also then have a second section here, which is $i is less than or equal to 10. That's going to be our point that we stop. So we're going to say start at one and as long as the number is less than or equal to 10, then keep going. And…

Contents