Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
ag47-pt avatar

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)
At a glance

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
From the docs

What powershell-windows says it does

Each cmdlet call MUST be in parentheses when using logical operators.
SKILL.md
**Rule:** Always specify `-Depth` for nested objects.
SKILL.md
npx skills add https://github.com/ag47-pt/website --skill powershell-windows

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars1
Last updatedJuly 3, 2026
Repositoryag47-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

SKILL.mdMarkdownGitHub ↗

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

Pattern:

$value = $obj.prop.sub
Write-Output "Value: $value"

---

5. Error Handling

ErrorActionPreference

ValueUse
StopDevelopment (fail fast)
ContinueProduction scripts
SilentlyContinueWhen 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

PatternUse
Literal pathC:\Users\User\file.txt
Variable pathJoin-Path $env:USERPROFILE "file.txt"
RelativeJoin-Path $ScriptDir "data"

Rule: Use Join-Path for cross-platform safety.

---

7. Array Operations

Correct Patterns

OperationSyntax
Empty array$array = @()
Add item$array += $item
ArrayList add`$list.Add($item)

---

8. JSON Operations

CRITICAL: Depth Parameter

❌ Wrong✅ Correct
ConvertTo-JsonConvertTo-Json -Depth 10

Rule: Always specify -Depth for nested objects.

File Operations

OperationPattern
Read`Get-Content "file.json" -Raw
Write`$data

---

9. Common Errors

Error MessageCauseFix
"parameter 'or'"Missing parenthesesWrap cmdlets in ()
"Unexpected token"Unicode characterUse ASCII only
"Cannot find property"Null objectCheck null first
"Cannot convert"Type mismatchUse .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.

CLI & Terminalbackenddevops

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.