PowerShell Genie

Write-Progress

Use Write-Progress to show a progress bar with a percentage, status text, and time remaining while a loop or long task runs.

Command 4 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — write-progress

Syntax

1PS> Write-Progress [-Activity] <String> [-Status <String>] [-PercentComplete <Int32>] [-CurrentOperation <String>] [-SecondsRemaining <Int32>] [-Id <Int32>] [-ParentId <Int32>] [-Completed] [<CommonParameters>]

Try it

Windows PowerShell

PowerShell example · browser support is limited.

Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

Interactive simulation · fictional data

Examples

Show progress inside a loop

1PS> for ($i = 1; $i -le 100; $i++) { Write-Progress -Activity 'Processing records' -Status "$i of 100" -PercentComplete $i Start-Sleep -Milliseconds 20 }
Show reference output

Illustrative output · values vary by environment

Processing records [ooooooooooooooooooooooooooooooooooooo         ]  75%

Show nested progress with parent and child bars

1PS> Write-Progress -Id 1 -Activity 'Migrating servers' -PercentComplete 40 Write-Progress -Id 2 -ParentId 1 -Activity 'Server 4 of 10' -PercentComplete 60
Show reference output

Illustrative output · values vary by environment

Migrating servers [██████████████░░░░░░░░░░░░░░░░░░░░]  40%
Server 4 of 10 [████████████████████░░░░░░░░░░░░]  60%

Close the bar when finished

1PS> Write-Progress -Activity 'Processing records' -Completed
Show reference output

Illustrative output · values vary by environment

(progress bar disappears)

Parameters

Parameter definitions:

  • -Activity — The title of the operation shown above the bar.
  • -Status — A short line under the title, such as 'File 12 of 40'.
  • -PercentComplete — A number from 0 to 100 that fills the bar.
  • -CurrentOperation — A detail line for the item currently being processed.
  • -SecondsRemaining — Estimated seconds left, shown next to the bar.
  • -Id / -ParentId — Ids that let a child bar nest under a parent bar.
  • -Completed — Closes the bar. Always call it when the task finishes, or the bar stays on screen.

Microsoft Learn — write-progress

Always close the bar, and do not update it every millisecond

A progress bar left open by a finished script stays on screen and confuses the next command's output. End every Write-Progress loop with Write-Progress -Activity ... -Completed, even on error paths.

Updating the bar on every iteration of a fast loop slows the loop down, because rendering is expensive. Update every 10th or 100th item, or only when the percentage actually changes.

Percentages must be integers from 0 to 100. Compute them as [int](($i / $total) * 100) and guard against division by zero when the collection is empty.

Pause between steps with Start-Sleep

Write status lines with Write-Host

Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.

Recap

Write-Progress Use Write-Progress to show a progress bar with a percentage, status text, and time remaining while a loop or long task runs.

Next: Select String
Genie guideWrite-Progress

Write-Progress turns a silent loop into visible progress: an activity name, a status line, a percentage bar, and seconds remaining. Learn the loop pattern, nested bars, and how to close the bar when done. The console below is pre-loaded — run it, then change a value and run it again.