| name | powershell |
| description | PowerShell cmdlet conventions for this project. Apply when writing or reviewing any .ps1 or module file.
|
PowerShell Cmdlet Development Guidelines
Naming Conventions
-
Verb-Noun Format:
- Use approved PowerShell verbs (Get-Verb)
- Use singular nouns
- PascalCase for both verb and noun
- Avoid special characters and spaces
-
Parameter Names:
- Use PascalCase
- Choose clear, descriptive names
- Use singular form unless always multiple
- Follow PowerShell standard names
-
Variable Names:
- Use PascalCase for public variables
- Use camelCase for private variables
- Avoid abbreviations
- Use descriptive names
-
Alias Avoidance:
- Use full cmdlet names
- Avoid using aliases in scripts (e.g., use Get-ChildItem instead of gci)
- Document any custom aliases
- Use full parameter names
Example
function Get-UserProfile {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$Username,
[Parameter()]
[ValidateSet('Basic', 'Detailed')]
[string]$ProfileType = 'Basic'
)
process {
# Logic here
}
}
Parameter Design
-
Standard Parameters:
- Use common parameter names (
Path, Name, Force)
- Follow built-in cmdlet conventions
- Use aliases for specialized terms