Powershell can be used to download some files from internet or intranet. We can simply do it with Invoke-WebRequest.
Below is the code which can be used for this purpose :
Enjoy!
Below is the code which can be used for this purpose :
#-------------------------------------------------------------------------------------------------------------- #-- Script to Download file #-------------------------------------------------------------------------------------------------------------- function Download-File ([string]$url , [string]$target) { trap { echo "Error occured" continue } if ( !(Test-path $target )) { invoke-webrequest $url -OutFile $target } else { echo "Error : Directory does not exit!" } } #-------------------------------------------------------------------------------------------------------------- Download-File "http://site.foo.com/file.exe" "C:\temp" #--------------------------------------------------------------------------------------------------------------
Enjoy!
No comments:
Post a Comment