Skip to main content

This script can be used to define a file parameter path on a website and a "save" location in the script, when run the script will download the specified file to the set location.The script may be amended and used for any other purpose.

# Script:   Download Anything.ps1
# Purpose:  Downloads a file from the web to the specified file path.
# Author:   Paperclips
# Email:
# Date:     Nov 2011
# Notes:
# -Get-URL thisfile.txt
# -Get-URL C:\myfolder\thisfile.txt

$url = ""
$path = "C:\temp\thisisthefile.txt"
# param([string]$url, [string]$path)

if (!(Split-Path -parent $path) -or !(Test-Path -pathType Container (Split-Path -parent $path)))
    $path = Join-Path $pwd (Split-Path -leaf $path)

"Downloading [$url]`nSaving at [$path]"
$client = new-object System.Net.WebClient
$client.DownloadFile($url, $path)
#$client.DownloadData($url, $path)