Using Powershell to Download a File from the Internet

Downloading a File with Powershell

I saw a post on a Facebook page that was asking for help downloading a file from the internet.  This person wanted to download a BIOS update.  This can be done relatively easily.

Create a function to download a file.  We will do this by creating a new object with the System.Net.Webclient class.  Now we will call the DownloadFile method.  This function takes 2 inputs as parameters.  One for the URL to download the file.  The other for the destination on the computer to place it.

function Get-HTTPFile ($url,$file){
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url,$file)
}

Now we will provide the URL and call the function with the URL and path to the destination.

$url = "https://download.lenovo.com/pccbbs/thinkcentre_bios/fbjycyusa.exe"
Get-HTTPFile -url $url -file 'c:\temp\fbjycyusa.exe'

You can check the destination and you now should have a file!!

Here is the full script…enjoy!!

function Get-HTTPFile ($url,$file){
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($url,$file)
}

$url = "https://download.lenovo.com/pccbbs/thinkcentre_bios/fbjycyusa.exe"
Get-HTTPFile -url $url -file 'c:\temp\fbjycyusa.exe'

2 Comments

    • Carlos

      That is correct and there are other ways to accomplish it as well. The person asking for help actually was saying they were getting errors using Bitstransfer

      Reply

Leave a Reply

Your email address will not be published.