How to download a file using PowerShell?

Today I came across a nice and simple command for downloading files from the web. It is very simple but also very powerful.

Command: 

Invoke-WebRequest -Uri http://ipv4.download.thinkbroadband.com/50MB.zip -OutFile .\50MB.zip


What this command does is, downloading a 50 MB test file from thinkbroadband.com to your own computer and put it in your current path. In this example on my Desktop.

You can of cause easily change both the url for the file you want to download and the target location changing the -Outfile parameter.

Lets say you want to download a file every day and name the file with day of the day, you can use the following two commands:

$filename = Get-Date -Format "dd-MM"
Invoke-WebRequest -Uri http://212.183.159.230/200MB.zip -OutFile .\$filename.zip







Comments

Popular posts from this blog

Use PowerShell to Discover Network Switch and port number

How to get Public IP Using PowerShell

Use ChatGPT to write PowerShell Scripts