Getting started with PowerShell
Main
- Language Keywords and Grammar including control flow
- about Operators
- Flow Control
- about_ScriptBlocks (anonymous functions)
Grammar
Important Topics, Language quirks
For( ;; )
vs ForEach
vs ForEach-Object
- about_ForEach ( control loop)
- about_For ( control loop)
- ForEach-Object ( Note: this is a command, not a control loop )
It’s first argument is a ScriptBlock so it appears like a control loop.

return
verses break
in ForEach-Object
. Remember that the { ... stuff ... }
in this case is an anonymous function
, not a language control statementIt is a
parameter
to the ForEach-Object
. When not specified, it’s the -Process
Parameter Flow Control with language Keywords
Attributes for validation
- Attributes TOC
- see: ValidatePattern, ValidateLength, ValidateSet
- Parameter attribute
- Cmdlet attribute
Best Practices
- Strongly Encouraged Development Guidelines
- The PowerShell Best Practices and Style Guide <github.com/PoshCode/PowerShellPracticeAndStyle>