Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Download files using Windows's Powershell

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

For example, to put the file: http://www.51.cto.com/download/datainfo.cfg

Http://www.51.cto.com/download/ABK/full.ABK

Http://www.51.cto.com/download/FIN/full.FIN

Http://www.51.cto.com/download/PWR/full_of.PWR

Download to the local directory D:\ DZHSERVER\ 127\ CWDATA\

1. Type start powershell on the command line to start powershell, as shown in the figure is powershell

2. Let's type in the command in powershell

$client = new-object System.Net.WebClient

$client.DownloadFile ('# 1','# 2')

Among them, fill in the file download address in the location of # 1 and the save path of the download in the location of # 2 (note that you should use the single quotation marks of the English keyboard). In # 2, be sure to write the file name (for example: full_so.FIN) together, not just a path.

If most of the downloaded files can be written directly in the form of a script

127_download_crontab.ps1

$client = new-object System.Net.WebClient$client.DownloadFile ('$client.DownloadFile ('http://www.51.cto.com/download/PWR/full_of.PWR','D:\DZHSERVER\127\CWDATA\download\PWR\full_of.PWR'))

Right-click to choose to run script 127 _ download_crontab.ps1 using Powershell and found no download. Right-click to edit and click run footer.

Powershell generally disables script execution under initialization conditions. Whether the script can be executed depends on the execution strategy of the Powershell. Only the administrator has permission to change this policy. Non-administrator will report an error

View script execution policy through Get-ExecutionPolicy; change script execution policy through Set-ExecutionPolicy UnRestricted

The script execution policy type is: Microsoft.PowerShell.ExecutionPolicy; views all supported execution policies through [System.Enum]:: GetNames ([Microsoft.PowerShell.ExecutionPolicy]):

Unrestricted: with the highest permissions, you can execute any script without restriction.

Default: the default policy for Powershell: Restricted, which does not allow any script execution.

AllSigned: all scripts must be signed to run.

RemoteSigned: there are no restrictions on local scripts, but scripts from the network must be signed.

Now right-click and choose to run script 127 _ download_crontab.ps1 using Powershell.

If you want to set it in the scheduled task, you cannot run this script directly. We need to use bat to create a .bat file and enter the script that calls PS:

Powershell C:\ Users\ justin\ Desktop\ 127_download_crontab.ps1

After that, set bat in the planned task.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report