PoshCode Archive  Artifact [85c486c6f2]

Artifact 85c486c6f229f9e05bce6d643cd71768b329b8accc6f28f00e9b54b05d2b6f41:

  • File wget.ps1 — part of check-in [e25d90a499] at 2018-06-10 12:56:38 on branch trunk — The simplest form of WGet … will become Get-FromWeb or something … (user: Joel Bennett size: 1204)

# encoding: ascii
# api: powershell
# title: wget
# description: The simplest form of WGet … will become Get-FromWeb or something …
# version: 1.0
# type: script
# author: Joel Bennett
# license: CC0
# x-poshcode-id: 120
# x-archived: 2017-04-30T10:06:09
# x-published: 2008-01-22T09:48: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