我正在尝试使用 Windows powershell 从带有 Apache 网络服务器的 Linux 服务器下载文件到 Windows 2012 R2
注意 :: URL 是 HTTPS
$source = "https://uri"
$destination = "C:\path\file.txt"
$username = "admin"
$password = "@dfkl!f" | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($username,$password)
Invoke-WebRequest $source -OutFile $destination -Credential $cred
错误
Invoke-WebRequest : Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong
credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Apache/2.2.15 (CentOS) Server at url Port 443
当我通过浏览器键入凭据时,我可以下载,但通过 powershell 它显示错误的凭据