Produces correct, hardened Bash scripts — quoting, strict mode, traps, and macOS/Linux portability built in.
Coding
PowerShell
Avoid common PowerShell mistakes — output behavior, array traps, and comparison operator gotchas.
What it does
Output Behavior Everything not captured goes to output — even without or doesn't stop output — previous uncaptured expressions still output bypasses pipeline — use for display only, not data Assign to to suppress — cast also suppresses —
The skill document
Output Behavior
- Everything not captured goes to output — even without
returnorWrite-Output returndoesn't stop output — previous uncaptured expressions still outputWrite-Hostbypasses pipeline — use for display only, not data- Assign to
$nullto suppress —$null = SomeFunction [void]cast also suppresses —[void](SomeFunction)
Array Gotchas
- Single item result is scalar, not array —
@(Get-Item .)forces array - Empty result is
$null, not empty array — check withif ($result)carefully - Array unrolling in pipeline —
@(1,2,3) | ForEachsends items one by one +=on array creates new array — slow in loops, use[System.Collections.ArrayList],is array operator —,$itemwraps single item in array
Comparison Operators
-eq,-ne,-gt,-lt— not==,!=,>,<-likewith wildcards,-matchwith regex — both return bool-containsfor array membership —$arr -contains $item, not$item -in $arr(though-inworks too)- Case-insensitive by default —
-ceq,-cmatchfor case-sensitive $nullon left side —$null -eq $varprevents array comparison issues
String Handling
- Double quotes interpolate —
"Hello $name"expands variable - Single quotes literal —
'$name'stays as literal text - Subexpression for complex —
"Count: $($arr.Count)"for properties/methods - Here-strings for multiline —
@" ... "@or@' ... '@ - Backtick escapes —
`nfor newline,`tfor tab
Pipeline
$_or$PSItemis current object — same thing,$_more commonForEach-Objectfor pipeline —foreachstatement doesn't take pipeline-PipelineVariablesaves intermediate —Get-Service -PV svc | Where ...- Pipeline processes one at a time — unless function doesn't support streaming
Error Handling
$ErrorActionPreferencesets default —Stop,Continue,SilentlyContinue-ErrorAction Stopper command — makes non-terminating errors terminatingtry/catchonly catches terminating — setErrorAction Stopfirst$?is last command success —$LASTEXITCODEfor native commands
Common Mistakes
- No space before
{inif—if($x){works butif ($x) {preferred =is assignment in conditions — use-eqfor comparison- Function return array unrolls —
return ,@($arr)to keep array Get-Contentreturns lines array —-Rawfor single stringSelect-Objectcreates new object — properties are copies, not references
Cross-Platform
pwshis PowerShell 7+ —powershellis Windows PowerShell 5.1- Paths use
/or\—Join-Pathfor portable - Environment vars:
$env:VAR— works on all platforms - Aliases differ across platforms —
ls,catmay not exist, use full cmdlet names
Related skills
Use Python for practical project setup, dependency install, script execution, and environment troubleshooting with safe defaults. Use when tasks involve pypr...
Runs a coaching session with a contracted opening, short questions, dated commitments, and an exit designed at intake.
Write and debug PHP with strict types, context-aware escaping, and right-sized FPM and OPcache.
Diagnose and fix Visual Studio Code at the editor layer: settings scopes, debug, formatters, extensions, keybindings, remotes.
Execute terminal commands safely and reliably with clear pre-checks, output validation, and recovery steps. Use when users ask to run shell/CLI commands, ins...
More from Iván
Browse all skillsRun Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.
Create and critique visual artifacts with quantified rules for hierarchy, spacing, type scale, color, and layout.
Debug CSS mechanics and write component stylesheets grounded in named mechanisms, not trial-and-error.
Plans and runs self-directed learning as a system: exit test, spaced review, deliberate practice, and transfer proof.
Get Azure architecture, debugging, security, and cost reviews grounded in a live inventory of your subscription.
Diagnoses Java and JVM issues from exception messages to container OOM-kills, and writes Java code matching the configured JDK.