While there are quite a few ways to download files with powershell, my usual go to if I’m limited to strictly powershell is Invoke-WebRequest.
Here’s an example:
1 | Invoke-WebRequest https://urltofile.com/file -OutFile "C:\pathtofile.bleh" |
While not as elegant as say wget or curl, it does the trick when there are no other options besides powershell.
Speaking of wget and curl, here are links for both. They work extremely well with powershell and give you a ton more options.
https://eternallybored.org/misc/wget/
Added fun bonus. Here’s a little function that gives downloading via Invoke-WebRequest a little boost:
1 2 3 4 5 6 7 8 9 10 11 12 | function Download-File { Param ($url) $get_file_name = $url.Split("/")[-1] $ProgressPreference = 'SilentlyContinue' $file_size = (Invoke-WebRequest $url -Method Head).Headers.'Content-Length' $file_size_mb = $file_size/1MB Write-Host - $get_file_name Write-Host - $file_size_mb Megabytes write-Host - Downloading file........ Invoke-WebRequest $url -OutFile $env:USERPROFILE\Downloads\$get_file_name write-Host - Download Finished! } |
By day, I’m a systems admin for a medium size company in the Pacific Northwest.
By night, I’m a blogger, gamer, and all around general nerd.
If you found one of my articles useful, please consider supporting this site!
Monero: 48PxwMvbwoB2M86sHespLBKcSL9cWxrnJDmga9XshSqRP1joykRNpKkDGUz4ohhxD1bMH92poMyZWBBqkPmQ2bHpLP4EDnz
Bitcoin: bc1qc0fyze8x9lxp42x5p3zpry6f0lsr6l5pgq4jkh
Ethereum: 0xc613cBc79Ea4a84AE5538ec3321E214363305121