Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PowerShell会话中正确退出远程作业_Powershell_Rpc_Invoke Command - Fatal编程技术网

如何在PowerShell会话中正确退出远程作业

如何在PowerShell会话中正确退出远程作业,powershell,rpc,invoke-command,Powershell,Rpc,Invoke Command,我有许多远程作业是用Powerhsellinvoke命令-session命令启动的。在某些情况下,至少有一个远程子作业退出,但本地PS会话状态将作业报告为“正在运行”,会话挂起,等待作业完成 这是PSv2中已知的错误吗?是否有一种变通方法或技术允许PS正确检测远程子作业何时退出?当您使用Invoke命令-Session时,我相信您需要使用Get-PSSession命令来获取更新的状态。发件人: -会议 在指定的Windows PowerShell会话(PSSessions)中运行该命令。输入包含

我有许多远程作业是用Powerhsell
invoke命令-session
命令启动的。在某些情况下,至少有一个远程子作业退出,但本地PS会话状态将作业报告为
“正在运行”
,会话挂起,等待作业完成


这是PSv2中已知的错误吗?是否有一种变通方法或技术允许PS正确检测远程子作业何时退出?

当您使用Invoke命令-Session时,我相信您需要使用Get-PSSession命令来获取更新的状态。发件人:

-会议


在指定的Windows PowerShell会话(PSSessions)中运行该命令。输入包含PSSessions的变量或创建或获取PSSessions的命令,例如新PSSession或Get PSSession命令。

如何:
删除PSSession

Get-PSSession | Remove-PSSession
Remove-PSSession -Session (Get-PSSession)
$s = Get-PSSession
Remove-PSSession -Session $s


您是否有代码显示您正在查看的对象或属性?您是否尝试查看会话的运行空间?[System.Management.Automation.RemoteRunspace]AvailabilityChanged事件?如何确定子作业已退出?
$r = Get-PSSession -ComputerName Serv*
$r | Remove-PSSession