Differences
This shows you the differences between the selected revisions of the page.
| 2017-06-02 | 2017-09-07 | ||
| no summary (martin) | Write-Progress example (martin) | ||
| Line 232: | Line 232: | ||
| Write-Host ("Error: {0}" -f $_.Exception.Message) | Write-Host ("Error: {0}" -f $_.Exception.Message) | ||
| exit 1 | exit 1 | ||
| + | } | ||
| + | </code> | ||
| + | |||
| + | If you want a pseudo-GUI progress bar, you can make use of ''[[ps>microsoft.powershell.utility/write-progress|Write-Progress]]'' cmdlet: | ||
| + | |||
| + | <code powershell> | ||
| + | function FileTransferProgress | ||
| + | { | ||
| + | param($e) | ||
| + | |||
| + | Write-Progress ` | ||
| + | -Activity "Uploading" -Status ("{0:P0} complete:" -f $e.OverallProgress) ` | ||
| + | -PercentComplete ($e.OverallProgress * 100) | ||
| + | Write-Progress ` | ||
| + | -Id 1 -Activity $e.FileName -Status ("{0:P0} complete:" -f $e.FileProgress) ` | ||
| + | -PercentComplete ($e.FileProgress * 100) | ||
| } | } | ||
| </code> | </code> | ||