PoshCode Archive  Artifact [cad3b34304]

Artifact cad3b34304b00fe132cb1519aa4436b2ace7cfba057d5ebcc9513e0912b75a73:

  • File Get-WebFile.ps1 — part of check-in [df948840bc] at 2018-06-10 12:56:39 on branch trunk — The simplest form of WGet … no options, no passwords, no nothing. But it works. (user: Joel Bennett size: 1222)

# encoding: ascii
# api: powershell
# title: Get-WebFile
# description: The simplest form of WGet … no options, no passwords, no nothing. But it works.
# version: 1.0
# type: script
# author: Joel Bennett
# license: CC0
# x-poshcode-id: 121
# x-archived: 2017-04-30T09:42:51
# x-published: 2008-01-22T09:51:00
#
#
# ---------------------------------------------------------------------------
### <Script>
### <Author>
### Joel "Jaykul" Bennett
### </Author>
### <Description>
### Downloads a file from the web to the specified file path.
### </Description>
### <Usage>
### Get-URL http://huddledmasses.org/downloads/RunOnlyOne.exe RunOnlyOne.exe
### Get-URL http://huddledmasses.org/downloads/RunOnlyOne.exe C:\Users\Joel\Documents\WindowsPowershell\RunOnlyOne.exe
### </Usage>
### </Script>
# ---------------------------------------------------------------------------
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 )

$path