Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi all is there a way we can show progress bar for 10 minutes with statistics of percentage completed how much time remaining for 10 Minutes? using Write-Progress.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
851 views
Welcome To Ask or Share your Answers For Others

1 Answer

If I understand the question correctly the goal is to show some additional information in the progress messages. This can be done for example by using the Activity parameter. The script below only shows the idea (for 1 minute, for a shorter test). It should be modified in order to reflect actually needed format of the message and information to be shown.

$time = 60 # seconds, use you actual time in here
foreach($i in (1..$time)) {
    $percentage = $i / $time
    $remaining = New-TimeSpan -Seconds ($time - $i)
    $message = "{0:p0} complete, remaining time {1}" -f $percentage, $remaining
    Write-Progress -Activity $message -PercentComplete ($percentage * 100)
    Start-Sleep 1
}

The progress looks like this:

57 % complete, remaining time 00:00:26
   Processing
   [oooooooooooooooooooooooooooooooooooooooooooooooooooooo

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...