powershell-windows

Audit Windows PowerShell scripts for common pitfalls and rewrite them safely.

Updated Aug 22, 2025
One-click install
npx skills add https://github.com/AnthonyCongHieu/voice_tool --skill powershell-windows-anthonyconghieu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: powershell-windows
Source: https://github.com/AnthonyCongHieu/voice_tool/tree/main/voice_tools_v1/.agent/skills/powershell-windows
Command: npx skills add https://github.com/AnthonyCongHieu/voice_tool --skill powershell-windows-anthonyconghieu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Windows administrators and developers write safer, more reliable PowerShell scripts by documenting critical patterns, common pitfalls, operator usage rules, and structured error handling.

Core Features & Use Cases

  • Operator syntax rules: Ensure cmdlets are wrapped in parentheses when combining with logical operators.
  • Null checks and safe access: Always validate objects before accessing properties to avoid null reference errors.
  • Error handling: Use Try/Catch blocks and set $ErrorActionPreference for reliable failure modes.
  • Path and file handling: Use Join-Path for cross-platform safety and predictable file paths.
  • JSON and data processing: Specify -Depth for nested JSON and use proper Read/Write patterns.
  • Use cases: Admin automation for Windows tasks, log processing, configuration checks, and deployment scripts.

Quick Start

Audit a Windows PowerShell script for common pitfalls and rewrite it to use ASCII-only characters, proper null checks, and robust 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 handle errors in PowerShell scripts for reliable automation?

Handle errors in PowerShell scripts by setting $ErrorActionPreference and wrapping cmdlets in Try/Catch blocks to ensure reliable failure modes. This approach captures terminating errors and prevents silent script failures during log parsing or deployment.

What is the correct way to join file paths in PowerShell?

Join file paths in PowerShell using the Join-Path cmdlet to ensure predictable, cross-platform safe path construction. This method avoids manual string concatenation pitfalls and ensures reliable file handling across different Windows environments.

Why does my PowerShell JSON output truncate nested data?

PowerShell JSON output truncates nested data when converting objects without specifying the -Depth parameter. Explicitly define -Depth during JSON read and write patterns to preserve complex nested structures and ensure complete data processing.

How do I avoid null reference errors when accessing object properties in PowerShell?

Avoid null reference errors in PowerShell by always validating objects and performing null checks before accessing properties. This safe access strategy prevents runtime exceptions when configuration management scripts encounter missing or empty data.

Do I need to wrap cmdlets in parentheses when using logical operators in PowerShell?

You must wrap cmdlets in parentheses when combining them with logical operators in PowerShell. Following this syntax rule ensures correct operator semantics and prevents unexpected boolean evaluation results in your scripts.

What are common PowerShell scripting pitfalls for Windows administrators?

Common PowerShell scripting pitfalls include improper null checks, missing JSON depth parameters, unsafe path joining, and unhandled errors. Mitigate these by using Try/Catch blocks, Join-Path, and structured script templating for safe automation.