Use this skill whenever executing PowerShell or pwsh commands via Bash. This includes any Bash tool call containing pwsh, powershell, or running .ps1 scripts. Triggers on any PowerShell execution — even simple one-liners. Ensures clean output with no ANSI escape sequences, no encoding errors, no progress bar artifacts, and no popup windows.
When running PowerShell commands through Bash, raw invocations produce broken output — ANSI escape codes, progress bar artifacts, encoding garbage, and popup windows. Every pwsh call must use the patterns below.
Always wrap PowerShell commands like this:
pwsh -NoProfile -NonInteractive -NoLogo -Command '
$PSStyle.OutputRendering = "PlainText"
$ProgressPreference = "SilentlyContinue"
$env:NO_COLOR = "1"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# your actual command(s) here
'
Every flag and preamble line serves a purpose:
-NoProfile — skips profile scripts that may print output or change settings-NonInteractive — prevents prompts and popup windows-NoLogo — suppresses the startup banner$PSStyle.OutputRendering = "PlainText" — disables ANSI escape sequences in output$ProgressPreference = "SilentlyContinue" — suppresses progress bars (Invoke-WebRequest, Install-Module, etc.)$env:NO_COLOR = "1" — signals no-color to tools that respect the NO_COLOR convention[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 — prevents encoding corruptionQuoting is the primary source of syntax errors when embedding PowerShell in Bash. Follow these rules strictly:
pwsh -Command '...'"PlainText", "SilentlyContinue"'\'' (end bash string, literal quote, resume bash string):
pwsh -NoProfile -NonInteractive -NoLogo -Command '
$PSStyle.OutputRendering = "PlainText"
$ProgressPreference = "SilentlyContinue"
$env:NO_COLOR = "1"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
Get-Content '\''C:\path\to\file.txt'\''
'
$() inside single-quoted Bash strings — it will not expand, which is what you want. PowerShell variables like $PSStyle pass through safely.pwsh -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File /tmp/script.ps1
When using -File, add the preamble lines at the top of the .ps1 script itself.Avoid cmdlets that produce formatted objects with ANSI decoration:
Select-Object over Format-Table or Format-ListConvertTo-Json or ConvertTo-Csv for structured dataOut-String -Width 200 if you need wide tabular output without truncationpwsh -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File ./script.ps1
If you do not control the script contents, prepend the preamble by wrapping:
pwsh -NoProfile -NonInteractive -NoLogo -Command '
$PSStyle.OutputRendering = "PlainText"
$ProgressPreference = "SilentlyContinue"
$env:NO_COLOR = "1"
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
& "./script.ps1"
'