Waiting for BITS downloads

I was preparing a personal laptop and had to update Windows 8 Pro in French using the Windows Store.
Once the first updates have been installed, I launched the upgrade to Windows 8.1 by executing ms-windows-store:WindowsUpgrade inside the Run window launched with the combination of the Windows key + R


The Windows store displays the following progress while downloading Windows 8.1


I’d like to see a percent of how much was downloaded so far. PowerShell to the rescue!
The old DOS command bitsadmin doesn’t help and you may even notice the message telling us that it’s deprecated and that we should use PowerShell instead.

The equivalent of the above DOS command in PowerShell is:

Get-BitsTransfer -AllUsers 


Now to get the progress of all the background intelligent jobs, I need to sum up the bytes transferred and the total bytes to be downloaded of each job.

while (Get-BitsTransfer -AllUsers | Where TransferType -eq "Download") {
	$transferred = Get-BitsTransfer -AllUsers | Measure-Object -Property BytesTransferred -Sum;
	$total = Get-BitsTransfer -AllUsers | Measure-Object -Property BytesTotal -Sum ;
	Write-Progress -Activity "Download" -Status ('{0:N2}' -f (($transferred.Sum/$total.Sum)*100)) ;
} 

The only drawback I know for the BITS module is that it cannot be used inside a remote session 😦
If I do:

Invoke-Command -ScriptBlock {
	Import-Module BitsTransfer
	Get-BitsTransfer -AllUsers
} -ComputerName remotePC

I’ve the following warning:

The remote use of BITS is not supported. For more information about BITS, see the MSDN documentation at http://go.microsoft.com/FWLINK/?LinkId=140888.
+ CategoryInfo : InvalidOperation: (:) [Get-BitsTransfer], InvalidOperationException
+ FullyQualifiedErrorId : GetBitsTransferRemoteOpException,Microsoft.BackgroundIntelligentTransfer.Management.GetBitsTransfer

+ CategoryInfo : NotSpecified: (:) [Get-BitsTransfer], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.BackgroundIntelligentTransfer.Management.GetBitsTransfer

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s