Downloads with Progress Bar

by Dec 2, 2008

If you'd like to download larger files from the Internet and get a progress indicator, you can load the .NET Visual Basic assemblies, which provide a sophisticated download method with progress bar:

$url = ''
$local = "$"
$object = New-Object Microsoft.VisualBasic.Devices.Network
$object.DownloadFile($url, $local, '', '', $true, 500, $true, 'DoNothing')

In case you are wondering what kind of arguments DownloadFile takes, look up the method. It's easy:

[System.Diagnostics.Process]::Start( `

The previous line used a static .NET method called Start(). Static methods do not come from a specific object, so you don't need New-Object. Instead, they are generic. Start() provided by the System.Diagnostics.Process class launches any command or file just as if you had pressed (WIN)+(R) and entered it into the Run dialog box. So you can use Start() to open Web pages in your default browser.