powershell-windows

Documents PowerShell syntax pitfalls, operator rules, and error handling patterns for Windows scripting.

41|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/DevayoshaUS/Women-scholarship --skill powershell-windows-devayoshaus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: powershell-windows
Source: https://github.com/DevayoshaUS/Women-scholarship/tree/main/hackathon-main%20%281%29/hackathon-main/.agent/skills/powershell-windows
Command: npx skills add https://github.com/DevayoshaUS/Women-scholarship --skill powershell-windows-devayoshaus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? PowerShell scripts frequently fail due to subtle syntax issues like missing parentheses around cmdlets in logical expressions, Unicode characters breaking parsers, and null reference errors. This Skill provides a reference of critical patterns and pitfalls so AI agents and developers write correct Windows PowerShell code the first time. ## Core Features & Use Cases - Operator Syntax Rules: Enforces parentheses around cmdlet calls in logical expressions to avoid "parameter 'or'" parser errors. - ASCII-Only Enforcement: Maps emoji and Unicode symbols to safe ASCII markers like [OK], [!], and [WARN] to prevent "Unexpected token" errors. - Null Checks and JSON Handling: Provides patterns for null-safe property access and mandates ConvertTo-Json -Depth for nested objects. - Use Case: When an AI agent generates a Windows automation script, it applies these rules to produce a script template with strict mode, try/catch error handling, and Join-Path file paths that runs without syntax failures. ## Quick Start Ask the agent to write a PowerShell script for your Windows task following the powershell-windows patterns, such as a script that reads a JSON config file and processes a list of files with proper error handling.

Frequently Asked Questions about powershell-windows

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix the PowerShell "parameter 'or'" error?▼

The "parameter 'or'" error occurs when cmdlet calls are used directly inside logical operators without parentheses. Wrap each cmdlet call in parentheses, for example if ((Test-Path "a") -or (Test-Path "b")), so PowerShell evaluates them as expressions.

Why does my PowerShell script fail with "Unexpected token"?▼

Unexpected token errors are commonly caused by Unicode characters like emoji or special symbols in script output. Replace them with ASCII markers such as [OK], [!], [WARN], or [INFO] to keep scripts parser-safe.

How do I safely convert nested objects to JSON in PowerShell?▼

Always pass the -Depth parameter to ConvertTo-Json, for example ConvertTo-Json -Depth 10, because the default depth truncates nested objects. When writing to files, pipe the result to Out-File with UTF8 encoding.

How do I avoid null reference errors in PowerShell scripts?▼

Check that variables are non-null before accessing properties, using patterns like $array -and $array.Count -gt 0 or if ($text) { $text.Length }. This prevents "Cannot find property" errors on uninitialized objects.

What ErrorActionPreference should PowerShell scripts use?▼

Use Stop during development to fail fast, Continue for production scripts, and SilentlyContinue only when errors are expected. Combine this with try/catch blocks, avoiding return statements inside try and using finally for cleanup.