【发布时间】:2015-08-17 11:57:38
【问题描述】:
我正在尝试通过 Windows Powershell 从远程 Exchange Server 接收所有 TransportAgent 的状态。
我偶尔收到一个错误,即The session state is Broken。一旦它被打破,我需要创建一个新的会话
下面是我正在使用的命令列表(按正确顺序)
# Build the PSSession for Exchange
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<SERVER>/PowerShell/ -Authentication Default
# Invoke the command 'Get-TransportAgent' on the remote PSSession
Invoke-Command $Session {Get-TransportAgent}
# Result when there is NO ERROR
Identity Enabled Priority PSComputerName
-------- ------- -------- --------------
Transport Rule Agent True 1 <SERVER>
Malware Agent True 2 <SERVER>
Text Messaging Routing Agent True 3 <SERVER>
Text Messaging Delivery Agent True 4 <SERVER>
当我重复命令Invoke-Command $Session {Get-TransportAgent} 时,偶尔会出现以下错误:
Invoke-Command : Because the session state for session Session9, <GUID-REMOVED>, <SERVER> is not equal to Open, you cannot run a command in the session. The session state is Broken. At line:1 char:1
更新
在 SessionOption 中添加 IdleTimeout 后,我收到以下错误,然后是 Session is Broken
Invoke-Command $Session {Get-TransportAgent}
Starting a command on the remote server failed with the following error
message : The I/O operation has been aborted because of either a thread exit or an application request. For more information, see the about_Remote_Troubleshooting
Help topic.
+ CategoryInfo : OperationStopped: (<SERVER>:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : JobFailure
+ PSComputerName : <SERVER>
问题:为什么会出现错误以及如何解决?
【问题讨论】:
标签: powershell exchange-server powershell-remoting