powershell-windows

Installation
Summary

Essential syntax rules and pitfalls for Windows PowerShell scripting.

  • Parentheses required around all cmdlet calls when using logical operators (-or, -and); missing them causes parsing errors
  • Unicode and emoji characters prohibited in scripts; use ASCII-only alternatives like [OK], [!], [WARN] for status indicators
  • Null checks mandatory before property access; always validate objects exist before calling methods or accessing properties
  • JSON operations require explicit -Depth parameter to serialize nested objects correctly
  • Error handling via $ErrorActionPreference and try/catch patterns; avoid returning inside try blocks and use finally for cleanup
SKILL.md

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.


Related skills
Installs
1.5K
GitHub Stars
37.3K
First Seen
Jan 20, 2026