Archives

Download files from the command line in Windows

Probably you will not need too often to download files from the command line/PowerShell, but in case you need, we will show here how you can archive this task.

In Linux, we have two commands to download files – wget and curl. Windows OS has the curl command. The curl command came to Windows in 2008.

To get the file content from the command line/PowerShell use curl URL

C:\Users\Web>curl plothost.com/kb
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://plothost.com/kb/">here</a>.</p>
</body></html>

C:\Users\Web>

To save the file on the local disk use curl URL -o local_filename

C:\Users\Web>curl http://plothost.com/test_file -o test_file.test
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2054k  100 2054k    0     0   342k      0  0:00:06  0:00:06 --:--:--  420k

C:\Users\Web>

The -o option will output the content to a file instead of the terminal.

-o, –output Write to file instead of stdout

curl –help

To see all curl options, use curl –help.

If you are using Windows PowerShell, you can also use the Invoke-WebRequest command.

The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements.

Invoke-WebRequest Doc

PS C:\Users\Web> Invoke-WebRequest http://plothost.com/test_file -o test_file.test
PS C:\Users\Web>

Related articles:
Download files in Linux

Resources:
Invoke-WebRequest

Share this post:

How to get Serial Number in Windows

There a few ways to get the serial number of a computer:

1. In the case of laptops, you will usually find the serial number on a back-label.

2. You can see it in BIOS (basic input/output system)

3. You can get it from Windows OS.

How to get the Serial Number in Windows:

1. Right-click on the Start button and click on the Windows PowerShell entry (or Command Prompt if you are using an older version of Windows).

Right-click StartMenu

The Windows PowerShell window will open:

Windows PowerShell

2. Here you can use two commands. The first one will work both on Command Prompt and on PowerShell:

wmic bios get serialnumber

C:\Users\PH>wmic bios get serialnumber
SerialNumber
9E195841H


C:\Users\PH>

The second command will work only on PowerShell:

Get-WmiObject win32_bios | Format-List SerialNumber

PS C:\Users\PH> Get-WmiObject win32_bios | Format-List SerialNumber

SerialNumber : 9E195841H

PS C:\Users\PH>
Share this post: