How to Display a Progress Bar in PowerShell for a Silent Script?
Asked by
CodingNinja77
I'm working with a PowerShell script that runs quietly in the background, and I'm looking to create a separate script that shows a visible progress bar. The goal is to inform users about which line the source script is currently processing. For instance, when the script reaches a line that says '* application closed', I want the progress bar to display 'application closed'. Ideally, I'd like this progress bar to appear in a single window that will close after processing a specific line. Does anyone have suggestions on how to implement this?
Answers
Have you considered using the Write-Progress cmdlet? Itโs a built-in way to show a progress bar in PowerShell. You can call it from within your silent script to display updates as the lines are processed.
Reply to this answer
You could try using Start-Transcript along with Write-Progress. Alternatively, create your own counter within your loop (like using for, foreach, or while) and utilize Write-Verbose to display messages.
Reply to this answer
How are you executing the second script? Understanding how youโre waiting for it to finish can help us figure out the best way to communicate between your scripts.
Reply to this answer
Add your answer
Answers are reviewed before publication.
CodingNinja77: I tried using Write-Progress, but it didnโt work because the main script is silent. I need a way to link it to a viable progress bar that shows each processed line.