我正在尝试从外部HTTPS站点检索文件。我的代码在POSH 3.0中有效,但在POSH 4.0中,并没有那么多。我收到的消息如下。遇到相同问题的任何人都知道如何解决此问题或解决方法?
Invoke-WebRequest:
需要验证。
您必须通过身份验证才能访问此URL
网址:https://www.mywebsite.com
用户名:
在行:4 char:1
+ Invoke-WebRequest -Uri https://www.mywebsite.com/report.pdf ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-WebRequest],WebException
+ FullyQualifiedErrorId:WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
$pw = ConvertTo-Securestring -AsPlainText -Force -String "myPWD"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ("myUser",$pw)
Invoke-WebRequest -Uri https://www.mywebsite.com/report.pdf -Credential $cred -OutFile C:\report.pdf
答案 0 :(得分:1)
所以我发现即使我可以访问该网站并使用我的浏览器检索我的内容,McAfee Web Gateway也阻止了Powershell做同样的事情。一旦我们将URL列入白名单,BOOM就没问题了。感谢大家帮助我排除故障的其他想法!