This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12006|Reply: 1

PowerShell utilizes the WebClient to download files

[Copy link]
Posted on 1/17/2017 5:18:57 PM | | | |
Download the software through the command line under Windows, and it is more convenient to use the "ftp" command. The main reason is that there is no Linux command "wget" under Windows, but although cmd cannot be implemented, PowerShell is no problem.
This article uses PowerShell to complete the operation of command-line file download, which can broaden the coverage of command-line downloads. In the deployment templates in Microsoft Private Cloud and Hyper-V, you will always come across the day when you use it.

$client = New-Object "System.Net.WebClient"
$client. DownloadFile("http://www.maytide.net/info.txt","D:info.txt")
The first sentence is to define a class
The second sentence is to download through xxx, provide the download address, and then save the address locally.
But obviously, such a long English character is difficult to remember
=== PowerShell is too complicated======
We save the code below as aa.ps1

The code looks like it's 4 lines, isn't it more complicated? It's actually simpler.
Users can run "PowerShell .aa.ps1 download address local address" under CMD.
$args can pass input parameters, the above example uses to directly pass parameters when running the script, and after completing this script, it is easy to download it later.
If it is running under PowerShell, it is ".aa.ps1 download address local address"
The specific effect is shown in the figure below

This script does not verify errors, only wants to be fast. Big brothers, this is already very simple, if you want it to be too complicated, it is really hopeless.






Previous:PowerShell calls .net and subscribes to events [source code]
Next:Linux Remote Installation WDLinux No longer worries about accidental disconnection or compilation of MySQL stuck for a long time
 Landlord| Posted on 1/17/2017 5:25:20 PM |
PowerShell calls .net and subscribes to events [source code]
http://www.itsvse.com/thread-3466-1-1.html
(Source: Architect)
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com