PowerShell

How to download files via PowerShell (Start-BitsTransfer)

To download files from the Internet you can use the graphical interface or a command from the PowerShell module BitsTransfer. In this blog post, I show how to download files with Windows PowerShell.

The Module BitsTransfer

In order to download files we need the Cmdlet Start-BitsTransfer that can be found by exploring the commands of the Module.

Get-Command -Module BitsTransfer

Unbenannt.PNG

Downloading Files via PowerShell

Well, all we have to do is to provide an URL. For example, I would like to download and watch a Video from Technet about Windows Azure. The downloaded file should be saved in my Home Directory. So, I run

Start-BitsTransfer "http://video.ch9.ms/ch9/3202/b43a9daa-b0e7-4591-b1b9-14a4ab503202/AzureFridayEventGridBanisadr20170814_high.mp4" -Destination $Home

Unbenannt.PNG

Watching the Video via PowerShell

Once downloaded open the file with Invoke-Item.

Invoke-Item $Home\AzureFridayEventGridBanisadr20170814_high.mp4

Unbenannt.PNG

Downloading large files in Asynchronous Mode

If you are thinking about downloading large files you can do this without interrupting your work. The download then starts in the background. The good news are, that the download will even continue if you quit PowerShell. When you shut down your computer, the download will resume automatically after the next startup.

Example:

Start-BitsTransfer "http://video.ch9.ms/ch9/3202/b43a9daa-b0e7-4591-b1b9-14a4ab503202/AzureFridayEventGridBanisadr20170814_mid.mp4" -Destination $Home -Asynchronous

Unbenannt.PNG

To check the status of the download run

Get-BitsTransfer

Unbenannt.PNG

Important Note: To open the downloaded file, you have to complete the transfer.

Get-BitsTransfer | Complete-BitsTransfer

Once completed check your directory to find the file.

Get-ChildItem $Home -Filter *.mp4

Unbenannt.PNG

Categories: PowerShell

Tagged as: ,

1 reply »

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.