Powershell – Download File from the Internet using Net.WebClient Object

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Powershell – Download File from the Internet using Net.WebClient Object

You can tap into the wealth of .NET methods easily. Use New-Object to instantiate a new .NET class, and off you go.
For example, instantiate an instance of Net.WebClient and you can enable your PowerShell scripts to download files from the Internet:

$object = New-Object Net.WebClient
$url = 'http://download.microsoft.com/download/4/7/1/47104ec6-410d-4492-890b-2a34900c9df2/Workshops-EN.zip'
$local = "$home\powershellworkshop.zip"
$object.DownloadFile($url, $local)

This will download a great PowerShell workshop from Microsoft to your home folder. Unfortunately, the simple DownloadFile() method does not provide a progress indicator so depending on your Internet connection, it may take a couple of minutes until the command is processed.

Leave a Reply

Your email address will not be published. Required fields are marked *

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