Share via

Is there an official PowerShell style guide?

THEOBALD K 85 Reputation points
2026-05-18T18:40:35.66+00:00

Shortly after Java was released, Sun issued a style guide. I've been looking for an "official" (from Microsoft) style guide for PowerShell and the only thing I can find is a "PowerShell-Docs" guide, which mainly focuses on documentation, as one would expect. Sure, there are lots of third-party guides, which isn't very helpful if a group is trying to settle on a standard, since everyone will just search for the one that matches their arbitrary stylistic preferences. A standard written by the PowerShell group itself would be nice, particularly if it's one that's followed by people when adding code examples to the PS doc pages.

Windows for business | Windows Server | User experience | PowerShell

Answer accepted by question author

VPHAN 33,910 Reputation points Independent Advisor
2026-05-18T19:18:44.6766667+00:00

Hi THEOBALD K,

Microsoft does not maintain a traditional, static manifesto for PowerShell formatting in the way legacy languages do. Instead, the product group codified its formatting standards, security baselines, and best practices directly into an official linting module known as PSScriptAnalyzer. By installing this tool and enforcing its default rule set, your team is effectively applying Microsoft's canonical style guide, immediately eliminating the subjective nature of arbitrary formatting preferences.

The most practical method to establish this standard across your organization is to integrate PSScriptAnalyzer directly into your daily development workflows. You can customize these enforcement rules by modifying the editor configuration file located at %APPDATA%\Code\User\settings.json on Windows environments, allowing you to define your workspace baseline and toggle specific analyzer rules like PSUseDeclaredVarsMoreThanAssignments.

For teams engineering complex or compiled modules, pairing the automated syntax checks of PSScriptAnalyzer with the architectural rules outlined in Microsoft's Cmdlet Development Guidelines provides a complete, authoritative framework. Enforcing this module centrally within your continuous integration pipelines ensures that all repository commits automatically adhere to the official standard before they ever reach production infrastructure.

Hope this answer brought you some useful information. If it did, please hit “accept answer”. Should you have any questions, feel free to leave a comment.

VPHAN

Was this answer helpful?

1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Castorix31 91,871 Reputation points
    2026-05-20T07:20:44.0433333+00:00

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-05-18T18:40:49.04+00:00

    Yes. Microsoft publishes official guidance for PowerShell, but it is scoped to documentation and contributor practices rather than a single, all-encompassing “language style guide” like Java’s.

    For Microsoft-owned content, the relevant official resources are:

    1. PowerShell-Docs Contributor Guide and Style Guide
      These define how PowerShell examples, formatting, and general style should look in Microsoft documentation. They are the standards followed for examples on Microsoft Learn. Key entry points are:
      • PowerShell contributor guide overview
      • Markdown best practices
      • PowerShell-Docs style guide
      • Editorial checklist
        These are referenced as the baseline for Azure PowerShell docs as well.
    2. Azure PowerShell docs style guide
      This is an official extension of the PowerShell-Docs guidance for Azure PowerShell content. It specifies, for example:
      • How to format cmdlet names and syntax elements in text (use backticks and a separate References section for cmdlets like Connect-AzAccount and Get-AzVM).
      • Parameter ordering (follow the order defined in cmdlet help and the parameter set being demonstrated).
      • Variable usage (avoid reusing variables across code blocks unless explicitly called out).
      • Security-related conventions (use Read-Host -MaskInput for passwords, avoid hardcoded passwords, use Get-Random to avoid naming conflicts).
      • When to use azurepowershell vs azurepowershell-interactive code fences.
      • Prohibition on using deprecated AzureRM cmdlets in new docs.
    3. Developer guidance and advisory guidelines
      For cmdlet and API developers, there are additional guidelines such as the Advisory Development Guidelines, which include code-related recommendations (for example, how and when to use SecureString). These are more about API and cmdlet implementation than script layout, but they are official style and design guidance from the PowerShell team.

    In practice, for a team standard that aligns with Microsoft’s own practices:

    • Use the PowerShell-Docs style guide and Editorial checklist as the primary style reference for script and example formatting.
    • For Azure-related scripts, layer on the Azure PowerShell docs style guide rules.
    • For cmdlet or module development, follow the developer/cmdlet guidance and advisory guidelines.

    There is no separate, single “universal” PowerShell coding style document beyond these, but these are the official sources Microsoft uses for its own PowerShell documentation and examples.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.