Animated Loading Spinner in PowerShell

Cycle through spinner characters to show activity during a wait.

WindowsTerminalpowershellproductivityLow risk
Run the snippet to animate a spinner in the console.

01Command

Command
$ $chars = "|","/","-","\"; 1..20 | ForEach-Object { Write-Host -NoNewline "`r$($chars[$_ % 4]) Working..."; Start-Sleep -Milliseconds 150 }

02What it does

The loop indexes into an array of four frame characters and rewrites the same line using a carriage return and -NoNewline, giving a smooth spinner. Wrap your long task in the loop body to use it as a real progress indicator.

03Risk

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: The backslash must be escaped in the PowerShell array; keep the frame set to single characters.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Write-Host
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Writes to the host; -NoNewline and carriage returns drive the animation.

Last verified: 2026-09-20 · Category: Developer

06Related solutions