— New online course!  Azure App Services & App Service Security with ASP.NET Core — Special launch price 50% off —

How to download a file on Windows Core


Windows Core is great.  Smaller disk footprint.  Less memory usage.  Boots up super-fast.  But with these benefits comes some caveats — for example, no web browser.

So then when you need to download a file or download an installer, how do you do it?  The answer is…POWERSHELL TO THE RESCUE!!!

Here’s a PowerShell script to download a URL to a local file.

 [Parameter(Mandatory=$true, HelpMessage='URL of to download')]
 [Parameter(Mandatory=$true, HelpMessage='Save to filename')]

$toFilename = "$PSScriptRoot\$saveAsFilename"

Write-Output "Downloading '$url' to '$toFilename'..."

Invoke-WebRequest -uri $url -outfile $toFilename

Write-Output "Downloaded."

Save this file to your Windows Core machine and rename it to end with *.ps1.

It takes two args: -url and -saveAsFilename.  The ‘url’ arg is the url to the file that you want to download.  FYI, it doesn’t follow HTTP redirects so you’ll need to get the exact url to download.  The ‘saveAsFilename’ arg is the name of the file that will be written to disk.

Here’s the link to that script again.

I hope this helps.


2 Responses to "How to download a file on Windows Core"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: