简体   繁体   English

写入进度10分钟PowerShell

[英]Write-Progress for 10 Minutes PowerShell

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? 大家好,有一种方法,我们可以显示进度条10分钟,统计百分比完成了10分钟的剩余时间? using Write-Progress. 使用Write-Progress。

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. 这可以通过使用Activity参数来完成。 The script below only shows the idea (for 1 minute, for a shorter test). 下面的脚本只显示了这个想法(1分钟,更短的测试)。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM