Frameworks#

PowerShell’s framework scene is narrower than the zsh ecosystem and broader than bash. The work that earns structure is mostly testing, linting, logging, and CI / automation hosts. Prompt management is shared with the rest of the shell world (Starship, oh-my-posh).

Testing#

  • Pester, the de-facto BDD test framework. Describes / contexts / its; Should for assertions; Mock for dependency stubbing. Ships with Windows; install latest from the gallery elsewhere.

Install-Module Pester -Scope CurrentUser

# MyModule.Tests.ps1
Describe 'Get-Thing' {
    It 'returns expected output' {
        Get-Thing -Path '.' | Should -BeOfType [string]
    }
    It 'handles missing input' {
        { Get-Thing -Path 'missing' } | Should -Throw
    }
}

Invoke-Pester ./MyModule.Tests.ps1

Linting#

  • PSScriptAnalyzer, the standard PowerShell linter. Catches missing [CmdletBinding()], unapproved verbs, alias use in scripts, parameter validation gaps. CI gate of choice.

Install-Module PSScriptAnalyzer -Scope CurrentUser
Invoke-ScriptAnalyzer -Path ./script.ps1
Invoke-ScriptAnalyzer -Path ./Module -Recurse -Severity Error

Logging / Output#

  • PSFramework, structured logging, configuration, async runspace pools. The closest thing PowerShell has to a “standard library” of operational primitives.

  • Microsoft.PowerShell.PlatyPS, generates external help (.md → MAML).

  • Built-in: Write-Verbose, Write-Information, Write-Warning (the Information / Verbose streams).

CLI / Argument Parsing#

Native: param(...) plus [CmdletBinding()] plus [Parameter()] and [Validate*()] attributes. No third party needed for any normal script.

function Send-Backup {
    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [Parameter(Mandatory)]
        [ValidateScript({ Test-Path $_ -PathType Container })]
        [string]$Source,

        [Parameter(Mandatory)]
        [ValidatePattern('^https://')]
        [string]$Endpoint,

        [int]$RetryCount = 3,

        [switch]$Force
    )
    process { ... }
}

The result is a cmdlet with full -WhatIf / -Confirm / -Verbose support, tab-completion on parameter names, and input validation at the boundary.

Async / Concurrency#

  • Built-in: ForEach-Object -Parallel (7+), Start-Job, Start-ThreadJob, runspace pools through [runspacefactory].

  • PoshRSJob, runspace- based jobs library (was the standard before ForEach-Object -Parallel shipped).

Automation Hosts#

Where PowerShell scripts actually run unattended.

  • GitHub Actions / Azure DevOps, both have first-class PowerShell tasks; the runner brings pwsh 7+.

  • PowerShell Universal, web UI, REST APIs, dashboards, and scheduled scripts in one bundle.

  • Azure Automation / AWS Systems Manager, cloud-managed schedule + execution for PowerShell scripts; the operator gets logging, retry, and credential vaulting for free.

  • Cron / systemd timers, on Linux, the same way bash scripts are scheduled. pwsh -File ./script.ps1.

Configuration Management#

Prompt Managers#

PowerShell shares the cross-shell prompt managers most operators use.

  • Starship, cross-shell prompt in Rust. Works in PowerShell, zsh, bash, fish, nu.

  • oh-my-posh, the PowerShell-first prompt manager; theme library, async git, transient prompts.

References#