powershell-windows

Enforce safe Windows PowerShell scripting patterns for operators, null checks, and error handling.

4|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/marcusagm/Mundam --skill powershell-windows-marcusagm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: powershell-windows
Source: https://github.com/marcusagm/Mundam/tree/main/.agent/skills/powershell-windows
Command: npx skills add https://github.com/marcusagm/Mundam --skill powershell-windows-marcusagm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Windows PowerShell scripting often suffers from fragile operator handling, non-ASCII characters, unsafe path handling, and inconsistent error management, leading to hard-to-maintain scripts. This skill provides a structured set of patterns to write robust, portable PowerShell scripts on Windows.

Core Features & Use Cases

  • Operator syntax rules: always place cmdlets within parentheses when using logical operators to avoid precedence errors.
  • ASCII-only scripting: enforce ASCII characters to maximize compatibility and reduce encoding issues.
  • Null checks and safe access: promote explicit null checks before accessing properties or collection members to prevent runtime errors.
  • Reliable error handling: provide guidance on using Try/Catch, error actions, and consistent exit codes.
  • File and path handling: recommend Join-Path and safe path construction for cross-version scripts.
  • JSON and data handling: specify proper Depth for ConvertTo-Json and robust parsing patterns.
  • Script template: include a default template to start new scripts with strict mode and consistent structure.

Quick Start

Review a Windows PowerShell script and rewrite it to comply with the listed patterns: ensure parentheses around cmdlets with logical operators, ASCII-only content, explicit null checks, robust error handling, and safe path construction.

Frequently Asked Questions about powershell-windows

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

FAQPage Schema
How do I handle errors safely in PowerShell scripts using Try Catch?

To handle errors safely in PowerShell scripts, use Try/Catch blocks with explicit error actions and consistent exit codes to ensure reliable execution and prevent silent failures during automation tasks.

Why does my PowerShell script fail with operator precedence errors?

PowerShell operator precedence errors occur when cmdlets are not wrapped in parentheses alongside logical operators, causing unexpected evaluation order and breaking your script's conditional logic flow.

What is the best way to check for null values before accessing properties in PowerShell?

The best way to check for null values in PowerShell is performing explicit null checks before accessing properties or collection members, which prevents runtime errors and ensures safe property access.

How do I construct safe file paths in PowerShell for cross-version compatibility?

Construct safe file paths in PowerShell by using Join-Path and safe path construction methods, which ensures cross-version script compatibility and prevents directory traversal vulnerabilities.

Does PowerShell ConvertTo-Json require specifying a depth parameter?

PowerShell ConvertTo-Json requires specifying a proper Depth parameter to ensure complete object serialization, preventing data truncation when converting complex nested objects to JSON format.

Why should I enforce ASCII-only characters in Windows PowerShell scripting?

Enforce ASCII-only characters in Windows PowerShell scripting to maximize compatibility across different environments and reduce encoding issues that cause unexpected runtime failures or data corruption.