Downloading Files from the Internet

by Dec 1, 2008

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 = ''
$local = "$"
$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.