10 分钟的写入进度 PowerShell [英] Write-Progress for 10 Minutes PowerShell

查看:60
本文介绍了10 分钟的写入进度 PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,有没有办法可以显示 10 分钟的进度条,并统计完成 10 分钟的剩余时间?使用写入进度.

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.

推荐答案

如果我正确理解了这个问题,目标是展示一些额外的进度消息中的信息.例如,这可以通过使用Activity 参数.下面的脚本只显示了这个想法(1 分钟,较短的测试).应该修改以反映实际需要的格式要显示的消息和信息.

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
}

进度如下:

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

这篇关于10 分钟的写入进度 PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆