Write-Progress Help

This topic contains 2 replies, has 2 voices, and was last updated by  Lery 4 years, 4 months ago.

  • Author
    Posts
  • #8537

    Lery
    Participant

    In my script I have a Try and Catch block.  Inside my catch block I'm calling five functions.  These functions take a minute or two to complete. I would love to show my end user a progress bar when these functions are executing.  I've asked the Google this question.  It returns varying results, but none that make it clear how I should handle this.  I'm curious if anyone has some pointers?

    Since I have 5 functions I figure I could just write-progress for each function starting at 20% and increasing until the 5th one is done.

  • #8557

    Art Beane
    Member

    Put a line like this just before each of your 5 steps, but use 99 for the percent at the last item:

    Write-Progress -Activity "Processing Catch Actions" -CurrentOperation "What I'm Doing Now" -PercentComplete 20
    

    Put a line like this at the end of the catch block:

    Write-Progress -Activity "Processing Catch Actions" -Completed
    
  • #8564

    Lery
    Participant

    Thank you very much Art.  Just what I needed.

You must be logged in to reply to this topic.