I'm making a syllabus to teach non-programmer co-workers PowerShell. The first non-pilot group I will run the course with will be a team that deploys and configures one of our software products. They are bright intelligent motivated IT workers, but not programmers.

I intend to cover the basics (variables, arrays, functions, and loops), and then move onto examples that are close to their problem domain. I'm not married to a 4 hour class, if necessary I can expand it to two four hour classes.

I'm toying with the idea of skipping for and while loops and simply teaching ForEach-Object. I've personally used traditional for and while loops in powershell scripts, but they can always be rewritten as ForEach-Object loops with a bit of creativity. Part of me feels the good old for ($i=0 $i < foo; $i++) is a necessary fundamental before moving onto foreach, but the other part of me thinks that might be me clinging to my [Model M](http://en.wikipedia.org/wiki/Model_M) and my [K&R Bible](http://en.wikipedia.org/wiki/The_C_Programming_Language).

To draw an analogy to SQL, I'd never teach a CURSORs or other loops in a 4 hour class there because you're supposed to be able to do everything in SQL as a SET operation. In theory you should stick to the pipeline in PowerShell. I use for and while loops in PowerShell more often than I do do cursors and while loops in SQL. However, PowerShell is a scripting language and conventions are less strictly enforced and I also push the boundaries of powershell with inline C# and excessive dependencies on calling native .NET APIs. My audience will not be ding this.

For those not adept at powershell, I'm pretty sure you don't actually need a for or while loop. I use them, but that's because I have experience with other languages. For example if you only want the first 10 members of an array of 20 members:

```
1..20 | Select-Object -First 10 | ForEach-Object { Write-Host $_ }

```