我在桌面PowerShell中使用PSVersion 5.1.14393.2155。我正在尝试使用Invoke-WebRequest.所使用的Azure VM不是防火墙的一部分,所以我在这里不应该遇到任何问题或限制。
我收到以下错误:
Invoke-WebRequest -Method Post -Uri 'https://IpAddress/resource'
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line: 1
我在从catch块中的异常中获取相同的数据时遇到了一个小问题。
如果在不使用try/catch块的情况下调用Microsoft renders API,则会呈现以下错误消息:
Invoke-WebRequest : {"error":{"code":"ActiveRequestAlreadyExists","message":"Action is already in progress","target":"{security string redaction}"}}
At line
当调用-WebRequest访问500、401、403等时,如何捕获输出?当调用成功时,它将结果存储在$Response变量中,但是如果我点击401,它会抛出错误,但不会存储响应。
$Response = Invoke-WebRequest -Method HEAD -Uri 'https://site.contoso.com'
Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.
At line:1 char:13
+ $Response = Invoke-WebRequest
我对脚本很陌生。当我试图访问一个输入为xml的web服务时,我遇到了一些错误。
获取xml的内容,并且当我试图调用WebRequest时。
[xml]$sun= Invoke-WebRequest -Uri $uri -CalculateTax post -ContentType "String" -InFile $Input.OuterXml.
其中,$uri是具有服务url的变量,CalculateTax是服务的方法,$Input是具有获取错误的XML内容的变量
Invoke-WebRequest : A parameter cannot be found that mat