Last active
September 11, 2022 04:54
-
-
Save tabs-not-spaces/0f4fa9c2f814c585eb3a2cab1b54f1bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Watch-BitsTransfer { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[guid]$JobId | |
) | |
$perc = 0 | |
while ($perc -le 100 ) { | |
$jobState = Get-BitsTransfer -JobId $JobId | Select-Object BytesTransferred, BytesTotal | |
$percentCompleteState = ($jobState.BytesTransferred / $jobState.BytesTotal * 100) | |
$progressParams = @{ | |
Activity = "Downloading file" | |
PercentComplete = $percentCompleteState | |
Status = "$("{0:n2}" -f $($jobState.BytesTransferred / 1gb)) / $("{0:n2}" -f $($jobState.BytesTotal / 1gb)) : %$("{0:n2}" -f $percentCompleteState)" | |
} | |
Write-Progress @progressParams | |
Start-Sleep -Seconds 5 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment