This module supports both Windows PowerShell 5.1 and PowerShell 7.x across multiple platforms.
- Platform: Windows ONLY
- Shipping: Built into Windows 10/11
- Runtime: .NET Framework 4.x
- Status: Maintenance mode (no new features)
- Use Case: Legacy Windows systems, enterprise environments
- Platforms: Windows, macOS, Linux
- Runtime: .NET Core / .NET 5+
- Status: Active development
- Cross-platform: True cross-platform support
- Use Case: Modern, cross-platform scenarios
| Platform | PowerShell Version | Reason |
|---|---|---|
| Windows | 5.1 (Desktop) | Legacy Windows support |
| Windows | 7.5 (Core) | Modern Windows |
| macOS | 7.5 (Core) | Mac support |
| Linux | 7.5 (Core) | Linux support |
| Platform | PowerShell Version | Reason |
|---|---|---|
| macOS | 5.1 (Desktop) | Doesn't exist - Windows PowerShell is Windows-only |
| Linux | 5.1 (Desktop) | Doesn't exist - Windows PowerShell is Windows-only |
$IsWindows # True on Windows
$IsMacOS # True on macOS
$IsLinux # True on Linuxif ($PSVersionTable.PSVersion.Major -le 5) {
# This is PowerShell 5.1 on Windows
}# ❌ This fails in 5.1
$path = Join-Path $root "folder1" "folder2"
# ✅ This works in 5.1
$path = Join-Path -Path $root -ChildPath "folder1"
$path = Join-Path -Path $path -ChildPath "folder2"# ✅ Both work in 7.x
$path = Join-Path $root "folder1" "folder2"
$path = Join-Path -Path $root -ChildPath "folder1" -AdditionalChildPath "folder2"if ($IsWindows -or $PSVersionTable.PSVersion.Major -le 5) {
# Windows (any PowerShell version)
}
elseif ($IsMacOS) {
# macOS (PowerShell 7.x only)
}
else {
# Linux (PowerShell 7.x only)
}Always use sequential Join-Path calls for maximum compatibility:
$path = Join-Path -Path $base -ChildPath "subfolder"
$path = Join-Path -Path $path -ChildPath "file.txt"Use platform-appropriate variables:
# Windows
$cacheDir = Join-Path -Path $env:APPDATA -ChildPath "AppName"
# macOS
$cacheDir = Join-Path -Path $HOME -ChildPath "Library/Application Support/AppName"
# Linux
$cacheDir = if ($env:XDG_CACHE_HOME) {
Join-Path -Path $env:XDG_CACHE_HOME -ChildPath "AppName"
} else {
Join-Path -Path $HOME -ChildPath ".cache/AppName"
}# Test on Windows PowerShell 5.1
powershell.exe -Command "& .\scripts\Test-Module.ps1"
# Test on PowerShell 7.x
pwsh -Command "& .\scripts\Test-Module.ps1"- Windows runners: Test both 5.1 and 7.x
- macOS runners: Test 7.x only (5.1 not available)
- Linux runners: Test 7.x only (5.1 not available)
The Scripts/ folder contains colorscripts with artistic formatting that intentionally violates style guidelines. We exclude it from linting:
# Get module files only (exclude colorscripts)
$files = Get-ChildItem -Path './ColorScripts-Enhanced' -File -Recurse -Include *.ps1, *.psm1, *.psd1 |
Where-Object { $_.FullName -notlike '*Scripts*' }
# Lint only module files
foreach ($file in $files) {
Invoke-ScriptAnalyzer -Path $file.FullName -Settings './PSScriptAnalyzerSettings.psd1'
}✅ DO:
- Test PowerShell 5.1 on Windows
- Test PowerShell 7.x on all platforms (Windows, macOS, Linux)
- Use sequential Join-Path for compatibility
- Detect platform with version checks
❌ DON'T:
- Try to test PowerShell 5.1 on macOS/Linux (impossible)
- Use multiple arguments with Join-Path
- Assume platform variables exist in 5.1
- Lint colorscripts in Scripts folder