powershell-windows

Applies PowerShell syntax rules, error handling patterns, and pitfalls for Windows scripts.

Updated Mar 17, 2026
One-click install
npx skills add https://github.com/beliciobcardoso/mcp-postgres --skill powershell-windows-beliciobcardoso
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: powershell-windows
Source: https://github.com/beliciobcardoso/mcp-postgres/tree/main/.agent/skills/powershell-windows
Command: npx skills add https://github.com/beliciobcardoso/mcp-postgres --skill powershell-windows-beliciobcardoso

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing PowerShell scripts on Windows often leads to subtle bugs: missing parentheses around cmdlets in logical expressions, Unicode characters breaking parsers, null reference errors, and JSON serialization losing nested data. This Skill encodes the critical patterns and pitfalls so generated scripts work correctly the first time. ## Core Features & Use Cases - Operator Syntax Rules: Enforces parentheses around cmdlet calls in logical expressions to avoid "parameter 'or'" parser errors. - Safety Patterns: Covers null checks before property access, ASCII-only output conventions, and correct string interpolation of nested properties. - Error Handling & JSON: Provides try/catch templates, ErrorActionPreference guidance, and mandatory ConvertTo-Json -Depth usage for nested objects. - Use Case: When asked to write a Windows automation script that reads a JSON config, checks file paths, and logs status messages, the Skill ensures the output uses Join-Path, null-safe checks, ASCII status markers, and a strict-mode template. ## Quick Start Write a PowerShell script that reads a JSON config file, validates paths, and logs status messages following Windows best practices.

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 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 each expression separately.

How to write PowerShell scripts that handle errors correctly?▼

Set $ErrorActionPreference appropriately (Stop for development, Continue for production) and wrap logic in try/catch blocks. Avoid returning inside the try block, use finally for cleanup, and return results after the try/catch completes.

Why does ConvertTo-Json lose nested object data in PowerShell?▼

ConvertTo-Json defaults to a shallow depth, truncating nested properties. Always specify the -Depth parameter, such as ConvertTo-Json -Depth 10, to serialize nested objects fully.

Can PowerShell scripts use emojis or Unicode symbols in output?▼

Unicode characters and emojis can cause unexpected token errors and encoding issues in Windows PowerShell scripts. Use ASCII markers like [OK], [X], [WARN], and [INFO] instead for status output.

How do I safely check for null before accessing properties in PowerShell?▼

Test the variable before accessing its members, for example $array -and $array.Count -gt 0, or wrap access in if ($text) { $text.Length }. This prevents "Cannot find property" errors on null objects.