
Powershell Windows
- 1 installs
- 1 repo stars
- Updated July 3, 2026
- ag47-pt/website
powershell-windows is a Claude Code skill documenting critical Windows PowerShell scripting patterns and pitfalls.
About
This skill collects critical patterns and pitfalls for writing Windows PowerShell scripts. It covers operator syntax (parentheses around cmdlet calls with logical operators), ASCII-only output instead of Unicode/emoji, null-check patterns, error handling with ErrorActionPreference and try/catch, Windows path rules with Join-Path, array operations, and JSON with the -Depth parameter. A developer uses it to avoid common PowerShell mistakes and start from a strict-mode script template.
- Critical patterns and pitfalls for Windows PowerShell scripting
- Covers operator parentheses rules, ASCII-only output, null checks, error handling, paths, arrays, and JSON depth
- Includes a strict-mode script template and a common-errors table
Powershell Windows by the numbers
- 1 all-time installs (skills.sh)
- Ranked #468 of 550 CLI & Terminal skills by installs in the Skillselion catalog
- Data as of Jul 7, 2026 (Skillselion catalog sync)
powershell-windows capabilities & compatibility
Free; a reference skill with no API key.
- Capabilities
- powershell scripting · shell automation · error handling
- Use cases
- devops
- Platforms
- Windows
- Pricing
- Free
What powershell-windows says it does
Each cmdlet call MUST be in parentheses when using logical operators.
**Rule:** Always specify `-Depth` for nested objects.
npx skills add https://github.com/ag47-pt/website --skill powershell-windowsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 1 |
| Last updated | July 3, 2026 |
| Repository | ag47-pt/website ↗ |
What it does
Write correct Windows PowerShell scripts by following operator, null-check, error-handling, path, and JSON patterns.
Who is it for?
Developers writing or debugging Windows PowerShell scripts who keep hitting syntax and null-check pitfalls.
Skip if: Bash or cross-platform shells other than PowerShell.
When should I use this skill?
The user is writing a Windows PowerShell script and needs correct operator, null-check, path, or JSON patterns.
What you get
Scripts follow parentheses, ASCII-only, null-check, and JSON-depth rules with a strict-mode template.
- PowerShell scripting patterns
- strict-mode script template
By the numbers
- 10 numbered pattern sections
- 9 rows in the common-errors table
Files
PowerShell Windows Patterns
Critical patterns and pitfalls for Windows PowerShell.
---
1. Operator Syntax Rules
CRITICAL: Parentheses Required
| ❌ Wrong | ✅ Correct |
|---|---|
if (Test-Path "a" -or Test-Path "b") | if ((Test-Path "a") -or (Test-Path "b")) |
if (Get-Item $x -and $y -eq 5) | if ((Get-Item $x) -and ($y -eq 5)) |
Rule: Each cmdlet call MUST be in parentheses when using logical operators.
---
2. Unicode/Emoji Restriction
CRITICAL: No Unicode in Scripts
| Purpose | ❌ Don't Use | ✅ Use |
|---|---|---|
| Success | ✅ ✓ | [OK] [+] |
| Error | ❌ ✗ 🔴 | [!] [X] |
| Warning | ⚠️ 🟡 | [*] [WARN] |
| Info | ℹ️ 🔵 | [i] [INFO] |
| Progress | ⏳ | [...] |
Rule: Use ASCII characters only in PowerShell scripts.
---
3. Null Check Patterns
Always Check Before Access
| ❌ Wrong | ✅ Correct |
|---|---|
$array.Count -gt 0 | $array -and $array.Count -gt 0 |
$text.Length | if ($text) { $text.Length } |
---
4. String Interpolation
Complex Expressions
| ❌ Wrong | ✅ Correct |
|---|---|
"Value: $($obj.prop.sub)" | Store in variable first |
Pattern:
$value = $obj.prop.sub
Write-Output "Value: $value"---
5. Error Handling
ErrorActionPreference
| Value | Use |
|---|---|
| Stop | Development (fail fast) |
| Continue | Production scripts |
| SilentlyContinue | When errors expected |
Try/Catch Pattern
- Don't return inside try block
- Use finally for cleanup
- Return after try/catch
---
6. File Paths
Windows Path Rules
| Pattern | Use |
|---|---|
| Literal path | C:\Users\User\file.txt |
| Variable path | Join-Path $env:USERPROFILE "file.txt" |
| Relative | Join-Path $ScriptDir "data" |
Rule: Use Join-Path for cross-platform safety.
---
7. Array Operations
Correct Patterns
| Operation | Syntax |
|---|---|
| Empty array | $array = @() |
| Add item | $array += $item |
| ArrayList add | `$list.Add($item) |
---
8. JSON Operations
CRITICAL: Depth Parameter
| ❌ Wrong | ✅ Correct |
|---|---|
ConvertTo-Json | ConvertTo-Json -Depth 10 |
Rule: Always specify -Depth for nested objects.
File Operations
| Operation | Pattern |
|---|---|
| Read | `Get-Content "file.json" -Raw |
| Write | `$data |
---
9. Common Errors
| Error Message | Cause | Fix |
|---|---|---|
| "parameter 'or'" | Missing parentheses | Wrap cmdlets in () |
| "Unexpected token" | Unicode character | Use ASCII only |
| "Cannot find property" | Null object | Check null first |
| "Cannot convert" | Type mismatch | Use .ToString() |
---
10. Script Template
# Strict mode
Set-StrictMode -Version Latest
$ErrorActionPreference = "Continue"
# Paths
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
# Main
try {
# Logic here
Write-Output "[OK] Done"
exit 0
}
catch {
Write-Warning "Error: $_"
exit 1
}---
Remember: PowerShell has unique syntax rules. Parentheses, ASCII-only, and null checks are non-negotiable.
Related skills
FAQ
Why does my PowerShell logical operator fail?
Each cmdlet call must be wrapped in parentheses when using logical operators, e.g. if ((Test-Path 'a') -or (Test-Path 'b')).
Why does ConvertTo-Json truncate nested objects?
Always specify -Depth (e.g. ConvertTo-Json -Depth 10) for nested objects.