From the course: PowerShell for SQL Server Administration

Unlock the full course today

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

Loops in PowerShell

Loops in PowerShell - PowerShell Tutorial

From the course: PowerShell for SQL Server Administration

Start my 1-month free trial

Loops in PowerShell

- [Instructor] So once we've got all our data back, and we've figured out how to run stored procedures, we've figured out how to run our select statements, the next thing is what do we do with this? We need to run through, we need to iterate through this data and figure out what we want to do and how we want to do it. So that iteration through data, that's going to be done through some sort of looping mechanism. So there's a few different ways we can do loops, and they all are going to do the same basic thing. We have for loops, we have foreach loops, we have do loops, we have while loops, and we have until loops, and these are all going to do the same basic thing, they're just written differently. So if we have a for loop, we loop through whatever the for is until we have an escape clause. So we need to put an escape clause in our for loop somewhere, so we basically do a for, and then under that for is going to be executed as a loop indefinitely until we escape out of that loop. If…

Contents