[英]Powershell remote: How to troubleshoot error code 14
我有一个powershell
脚本,它将远程运行长时间的测试。 测试将在那里运行几个小时。 请参阅下面的代码。
Invoke-Command -ComputerName $remoteIP -Credential $credential -ScriptBlock {
param ($runTestFolder,$runtestPath,$testsuiteOption)
if ($(Test-Path -Path $runtestPath) -eq $false) {
Write-Error "Run_Test.exe is not found from the path specified. "
return "ERROR_RUN_TEST.EXE_DO_NOT_EXIST"
}
cmd /c "cd $runTestFolder && $runtestPath /s $testsuiteOption"
return "COMPLETED."
} -ArgumentList $runTestFolder,$runTestPath,$TestSuiteOption
但大约两个小时后,它抛出了这个错误。 我该如何调试它? 我检查了“about_Remote_Troubleshooting”,但它根本没有提到错误代码。
Processing data for a remote command failed with the following error message: Error with error code 14 occurred while calling method WSManPluginReceiveResult. For more information, see the about_Remote_Troubleshooting Help topic.
根据New-SessionOption
MS Docs:
默认Microsoft.PowerShell session 配置的IdleTimeoutMs值为 7200000 毫秒(2 小时)。 它的MaxIdleTimeoutMs值为 2147483647 毫秒(>24 天)。 WSMan shell 空闲超时 (
WSMan:\<ComputerName>\Shell\IdleTimeout
) 的默认值为 7200000 毫秒(2 小时)。
替代方案是:
New-PSSession
,将IdleTimeout设置为最大值,并使用-Session
参数连接到它:$pso = New-PSSessionOption -IdleTimeout 2147483647
$pss = New-PSSession $remoteIP -Credential $credential -SessionOption $pso
Invoke-Command -Session $pss -ScriptBlock {
# script do something
}
Remove-PSSession $pss
Invoke-Command
上使用-SessionOption
参数:$pso = New-PSSessionOption -IdleTimeout 2147483647
Invoke-Command -ComputerName $remoteIP -ScriptBlock {
# script do something
} -Credential $credential -SessionOption $pso
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.