Skip to content

PowerShell naming conventions

These rules extend the general naming conventions. PowerShell adds one hard constraint the other languages don't have: function verbs come from the approved list (Get-Verb). An unapproved verb makes Import-Module print a warning, fails PSScriptAnalyzer's PSUseApprovedVerbs rule, and — more importantly — breaks the user's expectation of what Remove- or Test- does.

Casing summary

Used for Casing Example
Functions Verb-Noun, PascalCase parts, singular noun Get-MigrationFile, Invoke-SuiteTest
Parameters PascalCase -UpdateStartNumber, -TestFilter, -Yes
Local variables camelCase $fileList, $suiteResult
Script-scope variables and constants PascalCase with $script: $script:TestDefaultKeys, $script:DebeeFailed
Environment variables SCREAMING_SNAKE_CASE $env:DBDESTDB, $env:PGHOST
Classes / enums (when used) PascalCase [TestResult]
Hashtable / pscustomobject keys PascalCase @{ Name = ...; IsolationMode = ... }

Verbs — the Bliss registry mapped to approved verbs

Use the approved verb that carries the Bliss meaning. Never invent one.

Bliss verb PowerShell verb Example
Create New (a new object / resource) · Add (into a collection) New-TestResult, Add-TestLineCount
Update Update (bring up to date) · Set (replace a value) Update-Database, Set-EnvVar
Delete Remove · Clear (empty it) Remove-TempWrapper, Clear-OutputFolder
Get Get Get-MigrationFile
Fetch (raw call to an outside system) Invoke Invoke-Psql, Invoke-Npm
Load (bring in and keep) Import Import-EnvFile
Search Search · Find (locate in a set) · Select (choose from a set) Find-Placeholder, Select-TestItem
Process (bulk) Invoke + a noun naming the batch Invoke-StageImport
Map ConvertTo / ConvertFrom ConvertTo-PosixPath
Parse ConvertFrom · Read (from a file) ConvertFrom-TestOutput, Read-TestManifest
Generate New (data) · Build (an artifact) New-VersionTable, Build-Package
Check / Is / Has / Can Test (returns [bool]) Test-NodeVersion, Test-TestNameMatch
Validate / Verify Assert (throws on failure) Assert-SearchPath
Ensure (create if missing) Initialize Initialize-OutputFolder
Copy Copy Copy-SpfxPackage
Send Send Send-Notification
Save (persist) Save · Export (a format) Save-Json, Export-Csv
Ask the user Confirm (yes/no) · Read (a value) Confirm-Production, Read-PasswordWithConfirm
Show to the user Show (a screen of text) · Write (a line) Show-DebeeHelp, Write-Info
Start / run something Invoke (and wait) · Start (and continue) Invoke-Tests, Start-DevServer
Prepare / init Initialize Initialize-Environment
Recreate Reset Reset-Database

Unapproved verbs we have used and their replacements: Exec- → Invoke-, Run- → Invoke- / Start-, Prepare- / Init- → Initialize-, Create- → New-, Recreate- → Reset-, Prompt- → Confirm- / Read-, Helper- (file name) → common.ps1.

Nouns

  • Singular (PowerShell convention): Get-MigrationFile returns zero or more files. Plural only when the noun is a single thing that is plural in the domain language (Invoke-Tests for the runTests operation, Get-LocalDependencies).
  • Specific, with the primary object (general rule): Invoke-SuiteTransaction, not Invoke-Transaction.
  • No abbreviations: Get-TestsDirectory rather than Get-TestsDir; established tool names stay (Psql, Spfx, Json).
  • A tool-wide prefix only for functions exported from a module (Get-DebeeVersion); script-internal functions don't need one.

CLI operations

A script that exposes named operations (-Operations runTests, updateDatabase) keeps the operation names as the user types them — they are the shared language across implementations and docs. The functions that implement them use approved verbs with the operation's noun:

Operation PowerShell Python
recreateDatabase Reset-Database recreate_database()
restoreDatabase Restore-Database restore_database()
updateDatabase Update-Database update_database()
runTests Invoke-Tests run_tests()
execSql Invoke-Sql exec_sql()
prepareVersionTable Initialize-VersionTable prepare_version_table()

Put the mapping in a comment next to the operation dispatch so a reader of the sister implementation finds the function.

Parameters

  • PascalCase, typed, with validation attributes instead of manual checks: [ValidateSet('py','sh','ps1')], [ValidateRange(0,999)], [Parameter(Mandatory)].
  • Switches for on/off ([switch]$Yes, [switch]$TestVerbose); never [bool] parameters.
  • Standard names where PowerShell has them: -Path, -Force, -WhatIf, -Verbose (via [CmdletBinding()]), -Confirm.
  • Arrays as [string[]]. To pass several values from pwsh -File, the caller can't — document -Command "& './x.ps1' -Operations a,b" instead.

Variables and scope

  • Locals camelCase, named for what they hold ($migrationFiles, not $files / $f).
  • Script-wide state is explicit: $script:DebeeFailed. Never rely on a function reading a caller's local variable through dynamic scope.
  • Constants are set once in the Constants region and not reassigned. Mark real constants read-only when it helps: Set-Variable -Name MigrationFilePattern -Scope Script -Option ReadOnly -Value '...'.
  • Don't shadow automatic variables: $input, $args, $error, $host, $matches, $event, $profile, $_.

File names

Kind Rule Example
Entry script (a command people run) kebab-case debee.ps1, build-spfx.ps1, deploy-spfx.ps1
Shared functions of a script family common.ps1, or <area>-helpers.ps1 common.ps1
Module PascalCase, matching the module name Debee.psm1, Debee.psd1
Single-purpose script named after its action (installer step) Verb-Noun.ps1 with an approved verb New-SignageOSUser.ps1, Enable-RemoteDesktop.ps1

Anti-patterns

  • Unapproved verbs (Run-Tests, Exec-Sql, Prepare-Environment).
  • Uncaptured output inside a function that returns data — $list.Add() without [void].
  • A native command without a $LASTEXITCODE check.
  • Write-Host for data someone might capture, or Write-Output for messages.
  • Aliases in scripts (%, ?, ls, cat) — write ForEach-Object, Where-Object, Get-ChildItem; aliases differ between platforms.
  • -match / -like on user input as a pattern without saying so — escape with [regex]::Escape() or use -eq / -clike deliberately.
  • Positional arguments to your own functions with more than one parameter — name them.