Install
openclaw skills install powershellAvoid common PowerShell mistakes — output behavior, array traps, and comparison operator gotchas.
openclaw skills install powershellreturn or Write-Outputreturn doesn't stop output — previous uncaptured expressions still outputWrite-Host bypasses pipeline — use for display only, not data$null to suppress — $null = SomeFunction[void] cast also suppresses — [void](SomeFunction)@(Get-Item .) forces array$null, not empty array — check with if ($result) carefully@(1,2,3) | ForEach sends items one by one+= on array creates new array — slow in loops, use [System.Collections.ArrayList], is array operator — ,$item wraps single item in array-eq, -ne, -gt, -lt — not ==, !=, >, <-like with wildcards, -match with regex — both return bool-contains for array membership — $arr -contains $item, not $item -in $arr (though -in works too)-ceq, -cmatch for case-sensitive$null on left side — $null -eq $var prevents array comparison issues"Hello $name" expands variable'$name' stays as literal text"Count: $($arr.Count)" for properties/methods@" ... "@ or @' ... '@`n for newline, `t for tab$_ or $PSItem is current object — same thing, $_ more commonForEach-Object for pipeline — foreach statement doesn't take pipeline-PipelineVariable saves intermediate — Get-Service -PV svc | Where ...$ErrorActionPreference sets default — Stop, Continue, SilentlyContinue-ErrorAction Stop per command — makes non-terminating errors terminatingtry/catch only catches terminating — set ErrorAction Stop first$? is last command success — $LASTEXITCODE for native commands{ in if — if($x){ works but if ($x) { preferred= is assignment in conditions — use -eq for comparisonreturn ,@($arr) to keep arrayGet-Content returns lines array — -Raw for single stringSelect-Object creates new object — properties are copies, not referencespwsh is PowerShell 7+ — powershell is Windows PowerShell 5.1/ or \ — Join-Path for portable$env:VAR — works on all platformsls, cat may not exist, use full cmdlet names