2012-11-11 41 views

回答

5

如果我正確理解問題,則目標是在進度消息中顯示一些額外的 信息。這可以通過使用參數 Activity參數完成。下面的腳本只顯示了想法(1分鐘, 更短的測試)。它應該被修改以便反映實際需要的格式 的消息和要顯示的信息。

$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