Skip to content

Instantly share code, notes, and snippets.

@goyuix
Created June 28, 2013 21:24
Show Gist options
  • Save goyuix/5888259 to your computer and use it in GitHub Desktop.
Save goyuix/5888259 to your computer and use it in GitHub Desktop.
PowerShell cmdlet to facilitate downloading files
function Download-File {
param(
[Parameter(Mandatory=$true, Position = 0)][string]$Uri,
[Parameter(Mandatory=$false, Position = 1)][string]$SaveAs
)
$loc = [System.IO.Path]::GetFullPath([System.IO.Path]::GetFileName($Uri))
if ($SaveAs) { $loc = [System.IO.Path]::GetFullPath($SaveAs) }
$wc = New-Object System.Net.WebClient
$wc.UseDefaultCredentials = $true
# I just need to add in proper proxy support
$wc.DownloadFile($Uri, $loc)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment