Did you know that there are many uses of Windows PowerShell, one of which is to download files directly from the internet. Although its function is almost the same as the Command Prompt, but basically PowerShell has more advantages.
If in Command Prompt, users will need additional tools to download files (such as WGET). Whereas in PowerShell, users can directly use the built-in features/commands which are certainly functionally similar to WGET the.
It’s not just about downloading files. Even in PowerShell, users can control almost all settings only with command code. Such as disabling or activating Windows Defender, installing programs, or even removing programs.
How to Download Files Via PowerShell
This method has limitations, where you can only download files via direct URLs. So make sure the URL can be accessed without authentication so that it can be downloaded completely.
Here is the command to download the file via PowerShell:
Invoke-WebRequest "https://urlhalaman/download/file.zip" -OutFile C:\file.zip
From the example command code above, when executed it will immediately download the file and save it on the drive C by the name file.zip. Please change the URL and also the output directory of the file.
And if you want to save files on drive C, make sure to run PowerShell as administrator so that file output can be created and no errors appear.
When the download starts, it will appear progress bar which looks like it’s using WGET. That way you don’t have to worry about how long the download process has taken.
Also read: How to Disable Windows Defender Through PowerShell
Addendum: Automatic Download and Unzip with PowerShell
As I said above that PowerShell has its own advantages over Command Prompt. And one of the other advantages is that it can extract files in ZIP archives easily.
The sample code below is a combination of the command code to download the file above, so you can adjust the file name and also the directory where the archive file is extracted.
Invoke-WebRequest "https://urlhalaman/download/file.zip" -OutFile C:\file.zip; Expand-Archive -LiteralPath C:\file.zip -DestinationPath C:\letak_extract\
Actually this method only uses 2 commands combined into one line, so it looks practical. The two commands are Invoke-WebRequest which serves to retrieve the contents of the URL that is written. And the other one is Expand-Archive which serves to manage ZIP files, or in this case is to extract them.
So at this point, do you understand how to download files with Windows PowerShell? There are many other things you can do in Windows PowerShell to speed things up. Some of it will continue to be shared on Blog Second.
Hopefully useful and good luck