PS C:\> Get-Standard

Models write PowerShell that runs. Not PowerShell you would ship.

The PowerShell Engineer Standard is one document that fixes that, and a set of tools that carry it into whatever you already use.

Prompt Disable AD accounts that have not signed in for 90 days.

Default a model, no standard
# Disables old accounts.
# Pass the number of days.
function Disable-StaleAccounts {
    param($Days)
    $results = @()
    $cutoff = (Get-Date).AddDays(-$Days)
    $users = Get-ADUser -Filter * -Properties LastLogonDate
    foreach ($u in $users) {
        if ($u.LastLogonDate -lt $cutoff) {
            Disable-ADAccount -Identity $u
            Write-Host "Disabled: $($u.Name)"
            $results += $u.Name
        }
    }
    return $results
}
14 issues against the Standard
With the Standard same task, done properly
function Disable-PSEStaleAccount {
    <# .SYNOPSIS Disables inactive AD accounts.
       .EXAMPLE Get-ADUser -Filter 'Enabled -eq $true' |
         Disable-PSEStaleAccount -InactiveDays 90 -WhatIf #>
    [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')]
    [OutputType('PSEngineer.AccountResult')]
    param(
        [Parameter(Mandatory, ValueFromPipeline)]
        [ValidateRange(1,3650)][int]$InactiveDays = 90 )
    process {
        $stale = $_.LastLogonDate -lt $cutoff
        if ($stale -and $PSCmdlet.ShouldProcess($_.Name)) {
            Disable-ADAccount -Identity $_ -ErrorAction Stop }
        [pscustomobject]@{ PSTypeName='PSEngineer.AccountResult'
            Name=$_.Name; Action=if($stale){'Disabled'}else{'Skipped'} }
    } }
14 issues against the Standard

PSScriptAnalyzer's default rules catch two of these. The Standard catches all fourteen.

What the Standard covers

  • Advanced functions, approved verbs, and [OutputType()] by default
  • Objects out, never formatted strings
  • SupportsShouldProcess on anything that changes state
  • Pipeline support that actually works
  • Errors you can catch, with the right terminating behavior
  • Help with three examples that run unmodified
  • Secrets that never reach a log, a stream, or a process argument
  • Comments and READMEs that do not read like they were generated
Read the full Standard

The tools

Each one is a way to deliver the Standard. The status is honest.

One command, and your repo has a standard

Install-Module PowerShellEngineer -Scope CurrentUser
Add-PSEStandard -Path .

Writes AGENTS.md, Cursor rules, Copilot instructions, an analyzer settings file, and a GitHub Action. Copilot, Cursor, and Claude Code read them without any extension installed.

Jim Tyler

Microsoft MVP and author of PowerShell for Systems Engineers. He runs the PowerShell Engineer channel on YouTube. This Standard is the checklist he stopped rewriting in every code review.