Downloading very large files can be a challenge because the download process may take longer than a machine is turned on. With BitsTransfer, you can download files in the background, and even if the computer is turned off or rebooted, the download will resume and eventually complete.
The code below downloads a NASA video for you. However, the download occurs in the background, and you can immediately continue. In fact, you can close PowerShell, or your computer altogether. When it restarts, the download resumes.
$url = 'https://mars.nasa.gov/system/downloadable_items/41764_20180703_marsreport-1920.mp4' $targetfolder = "$Home\Desktop" Start-BitsTransfer -Source $url -Destination $targetfolder -Asynchronous -Priority Low
All you need to do is look after the BitsTransfer once in a while, and check which download jobs have completed. Once a download completes, it is your duty to complete the download. Only then will the downloaded file be copied from the background buffer to the final destination:
Get-BitsTransfer | Where-Object Jobstate -eq Transferred | Complete-BitsTransfer
To get more information about pending BitsTransfer jobs, try this:
PS> Get-BitsTransfer | Select-Object -Property *
And if you have Admin privileges, you can even dump the jobs from other users, including internal accounts. This way you’ll see updates and other things that are on their way to you:
PS> Get-BitsTransfer -AllUsers