gpt4 book ai didi

excel - 运行 powershell 命令时出错

转载 作者:行者123 更新时间:2023-12-03 00:06:51 24 4
gpt4 key购买 nike

我收到以下错误:

exception calling "UploadString" with "2" argument(s): "The remote server returned an error: (500) 
Internal Server Error." At C:\Cinegy_Type\Helpers-Type.ps1:146 char:5 + $web.UploadString($url,
$xmlDoc.OuterXml) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [],
MethodInvocationException + FullyQualifiedErrorId : WebException

方法是这样的:
function Type-UpdateVariable([string]$name, [string]$value, [string]$type = "Text", [string]$server="localhost", [int]$instance=0)
{
#make a Type PostRequest XML document using .Net XML document object
$xmlDoc = New-Object System.Xml.XmlDocument;

#add root element for request - which is a 'PostRequest' element
$xmlRootElem = $xmlDoc.AppendChild($xmlDoc.CreateElement('PostRequest'));

#create SetValue element and define variable Name, Type and Value
$xmlSetValueElem = $xmlRootElem.AppendChild($xmlDoc.CreateElement('SetValue'));
$xmlSetValueElem.SetAttribute("Name", $name);
$xmlSetValueElem.SetAttribute("Type",$type);
$xmlSetValueElem.SetAttribute("Value", $value);

#create a .Net webclient which will be used to perform the HTTP POST
$web = new-object net.webclient

#Air requires that the data is in XML format and declared properly - so add the HTTP Header to state this
$web.Headers.add("Content-Type", "text/xml; charset=utf-8")

#perform the actual HTTP post to the IP and port (which is 5521 + instance number) of the XML data
$url = "http://" + $server + ":" + (5521 + $instance) + "/postbox"
$web.UploadString($url, $xmlDoc.OuterXml)
}

第 146 行是:
$web.UploadString($url, $xmlDoc.OuterXml)
我不明白的是,这是昨天工作的。

完整的代码可以在这里找到:(这里不要使用行号作为引用,这有 3 个脚本。)

https://pastebin.com/RtisgmiB

最佳答案

您发布到的网络服务器有问题; see meaning of a HTTP status code 500 .除非传递给您的函数的数据有问题,否则您的代码看起来不错。您在该 Powershell 错误消息中没有遗漏任何内容,这将为您提供有关该问题的线索。

  • 检查 Web 服务器上的错误日志(最佳选择)
  • 将参数输出到控制台,目的是通过Postman、cURL等手动提交请求。

  • 祝你好运!

    关于excel - 运行 powershell 命令时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59579879/

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