Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Introducing Slide Speaker: Videos with Voice-over from your PowerPoint and Google Slides Presentations

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.

[CmdletBinding()]
param(
 [Parameter(Mandatory=$true, HelpMessage='URL of to download')]
 [ValidateNotNullOrEmpty()]
 [string]
 $url,
 [Parameter(Mandatory=$true, HelpMessage='Save to filename')]
 [ValidateNotNullOrEmpty()]
 [string]
 $saveAsFilename)

$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.

-Ben

SUBSCRIBE TO THE BLOG


2 responses to “How to download a file on Windows Core”

  1. Arnold Villeneuve Avatar

    Great stuff. Thanks. Helped a lot.

  2. Dawesi Avatar
    Dawesi

    Import-Module bitstransfer

    start-bitstransfer -source http://something/something.ext -destination c:\something.ext

Leave a Reply

Your email address will not be published. Required fields are marked *

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