Write-Progress

noun

say it: “RYTE PROG-res” /ˈraɪt ˈprɑɡrɛs/

A PowerShell command that shows a progress bar while a long job runs, so it doesn't look stuck.

What does Write-Progress do?

Write-Progress draws a progress bar near the top of the window, so a long job doesn't look stuck. Call it once per step with how far along you are, and once more with -Completed to close it. The bar never goes down the pipeline or into a file.

$cards = Get-ChildItem .\old-cards -Filter *.txt
for ($i = 0; $i -lt $cards.Count; $i++) {
    Write-Progress -Activity 'Importing recipe cards' -Status $cards[$i].Name -PercentComplete ($i / $cards.Count * 100)
}
Write-Progress -Activity 'Importing recipe cards' -Completed

In a sentence

  • “Write-Progress showed card-03.txt and a bar a little under half full.”
  • “Sam closed the bar with Write-Progress -Completed.”

Level: Journeyman · More PowerShell terms at this level

Updated