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