gpt4 book ai didi

powershell - 如何使用powershell下载文件?

转载 作者:行者123 更新时间:2023-12-04 12:21:33 25 4
gpt4 key购买 nike

过去我确实使用过:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$url = "https://nodejs.org/dist/v14.17.6/node-v14.17.6-x64.msi"
$folder = "C:\Users\test\Downloads"

$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($url, $folder)
当我今天尝试时,它显示此错误
  Exception calling "DownloadFile" with "2" argument(s): "An exception occurred during a WebClient request."
At line:1 char:5
+ $WebClient.DownloadFile($url, $folder)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
我试图用找到的建议进行修复,但没有任何效果。

最佳答案

您需要提取文件名,以便获得输出文件的完整路径,但这将起作用:

$url = "https://nodejs.org/dist/v14.17.6/node-v14.17.6-x64.msi"
$fullPath = "C:\Users\test\Downloads\node-v14.17.6-x64.msi"
Invoke-WebRequest $url -outfile $fullPath

关于powershell - 如何使用powershell下载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69124584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com