我试图通过Windows Powershell从远程Exchange Server接收所有TransportAgents的状态。Exchange远程Powershell获取零星'Broken'状态
我偶尔会收到一个错误,那就是The session state is Broken
。一旦被打破,我需要当我重复命令来创建一个新的Session
下面我用命令的列表(按照正确的顺序)
# 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
UPDATE
在SessionOption添加的IdleTimeout后我recev荷兰国际集团下面的错误,然后会话被打破
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>
问题:为什么会出现错误,以及如何解决这个问题?
它仍然给我错误(请参阅我更新的问题)在不到10分钟,我会检查其他SessionOptions以及 - 谢谢 –
我设法发现,如果有任何形式的网络断开任何一方一个PSSession,会话中断。您只能调试本地和远程服务器之间的连接。可以对脚本进行修改,以便如果'$ session.state'不是'open',则可以指示脚本重新创建会话对象。 – Vesper
我恢复了远程服务器连接不良(往返,网络延迟问题),这导致'Broken'状态。 - 我将通过使用-NoEncryption和-NComCompression标志给它最后的机会。再次感谢 –