Download files from windows command line

command line

Use the built-in certutil tool that was designed to use for certificate management but it can be abused for downloading any arbitrary file

certutil -urlcache -f https://mydomain.com/reports/log.csv c:/path/to/log.csv

Download wget for windows from here: http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe then run:

wget https://mydomain.com/reports/log.csv

Download curl for windows from here: https://curl.se/windows/, then run:

curl https://mydomain.com/reports/log.csv --output log.csv

Using PowerShell 1:

Invoke-WebRequest -URI "https://mydomain.com/reports/log.csv" -OutFile log.csv

Using PowerShell 2:

(New-Object System.Net.WebClient).DownloadFile ("https://mydomain.com/reports/log.csv", "log.csv")

Using PowerShell 3:

Start-BitsTransfer -Source "https://mydomain.com/reports/log.csv" -Destination log.csv

Notice, to run powershell from command line use:

powershell -command "..."
or
powershell -file file.ps1

Post a Comment

Previous Post Next Post