java powershell出错_powershell基础连接已关闭:发送时发生意外错误

我是Powershell的新手并创建了一些断点来弄清楚脚本超时的原因 . 但我收到了以下错误 . 任何帮助,将不胜感激 .

使用“0”参数调用“GetRequestStream”的异常:“基础连接已关闭:发送时发生意外错误 . ”在C:\ Users \ ksingh \ Documents \ SQL scripts \ pdfimportPowerShell.ps1:155 char:5 $ requestStream = [System.IO.Stream] $ request.GetRequestStream()~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :NotSpecified:(:) [],MethodInvocationException FullyQualifiedErrorId:WebException

这是脚本的一部分,错误发生在---

bytes = [System.Text.Encoding]::ASCII.GetBytes($data)

函数调用令牌服务

function GetNewToken()

{

$request = [Net.WebRequest]::Create($temptokenserviceurl)

$request.ServicePoint.Expect100Continue = $false

$request.ContentType = "application/json"

$request.Method = "POST"

$data = (New-Object PSObject |

Add-Member -PassThru NoteProperty username $temptokenserviceuser |

Add-Member -PassThru NoteProperty password $temptokenservicepassword

) | ConvertTo-JSON

$bytes = [System.Text.Encoding]::ASCII.GetBytes($data)

$request.ContentLength = $bytes.Length

$requestStream = [System.IO.Stream]$request.GetRequestStream()

$requestStream.write($bytes, 0, $bytes.Length)

$response = $request.GetResponse()

$StreamReader = New-Object IO.StreamReader($response.getResponseStream())

$Json = $StreamReader.ReadToEnd()

$responseString = $Json | ConvertFrom-Json

$response.Close()

return $responseString.tokenId

}

你可能感兴趣的:(java,powershell出错)