Skip to content

Reference guide of PowerShell pitfalls and patterns for writing Windows scripts reliably.

CCM score
69 of 100
skills.sh installs
456
GitHub stars
34.3K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers operator syntax, Unicode restrictions, null checks, string interpolation, error handling, file paths, arrays, and JSON
  • Includes tables of wrong versus correct patterns, an error-message lookup table, and a script template with strict mode and try/catch
  • Enforces parenthesized cmdlet calls under logical operators, ASCII-only output, explicit -Depth on JSON conversion, and null checks before access
  • Designed for developers writing or reviewing Windows PowerShell scripts who want to avoid common parsing and runtime failures

Install

$ npx -y skills add davila7/claude-code-templates --skill powershell-windows -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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.Lengthif ($text) { $text.Length }

4. String Interpolation

Complex Expressions

❌ Wrong✅ Correct
"Value: $($obj.prop.sub)"Store in variable first

Details

Repository
github.com/davila7/claude-code-templates
Categories
CLI & Terminal, DevOps & Cloud
First seen
Jun 3, 2026

More from davila7/claude-code-templates

All 398

Similar to Powershell Windows

More CLI & Terminal