/PSStyleGuide

UnOfficilal PowerShell Style Guide

BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

PSStyleGuide

The Community PowerShell Style Guide

Contributing

Markdown documents on GitHub support linking to any header, so when editing, please observe the following conventions:

  1. Keep rules within the section where they make sense.
  2. Sections must be header level 3 (have three hashes): ### Naming Conventions
  3. Rules must be headers with an explanatory paragraph
  4. Rules should have examples and counter examples
  5. Rules should be phrased as the positive, rather than the negative.
  • Don't say: "Avoid using aliases"
  • Do say: "Use full command names"
  1. When writing a negative rule, you should always start with "avoid" and end with an "instead" sentence, like:
    Avoid the use of ~ to represent the home folder.

    The meaning of ~ is unfortunately dependent on the "current" provider at the time of execution. This isn't really a style issue, but it's an important rule for code you intend to share anyway. Instead, use ${Env:UserProfile} or (Get-PSProvider FileSystem).Home