Get-WebFile 1.0 by Joel Bennett 4 years ago
View followups from Joel Bennett | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/121"></script>download | new post
The simplest form of WGet … no options, no passwords, no nothing. But it works.
- # ---------------------------------------------------------------------------
- ### <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
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
PowerShell Code Repository