Formatting Your Code
Screen space should be conserved as much as possible while still allowing code formatting to reflect logic structure and nesting. Here are a few suggestions:
Indent standard nested blocks two spaces.
Block overview comments for a function. Block the highest level statements, with each nested block indented an additional two spaces.
You must line up curly brackets. This makes it easier to follow the code flow.
Avoid single-line statements. In addition to making it easier to follow the flow of the code, this also makes it easier when you search for a missing curly bracket.
Break each pipelined object at the pipe. Leave all pipes on the right.
Avoid line continuation—the grave accent (backtick or `). The exception here is when it would ...
Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.