title: Exchange Remote Powershell gets sporadic 'Broken' state
body: <p>I am trying receive the status of all TransportAgents from an remote Exchange Server through Windows Powershell.</p>
  
  <p>I sporadically receive an error, that the <code>The session state is Broken</code>. Once it is broken I need to create a new Session</p>
  
  <p>Below a list of the commands I am using (in proper order)</p>
  
  <pre><code># Build the PSSession for Exchange
  $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://&lt;SERVER&gt;/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               &lt;SERVER&gt;
  Malware Agent                                      True            2               &lt;SERVER&gt;
  Text Messaging Routing Agent                       True            3               &lt;SERVER&gt;
  Text Messaging Delivery Agent                      True            4               &lt;SERVER&gt;
  </code></pre>
  
  <p>When I repeat the command <code>Invoke-Command $Session {Get-TransportAgent}</code> the following error occured sporadically:</p>
  
  <pre><code>Invoke-Command : Because the session state for session Session9, &lt;GUID-REMOVED&gt;, &lt;SERVER&gt; is not equal to Open, you cannot run a command  in the session.  The session state is Broken. At line:1 char:1
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>After adding the IdleTimeout in SessionOption I'm receving the below error followed by <strong>Session is Broken</strong></p>
  
  <pre><code>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: (&lt;SERVER&gt;:String) [], PSRemotingTransportException
  + FullyQualifiedErrorId : JobFailure
  + PSComputerName        : &lt;SERVER&gt;
  </code></pre>
  
  <p>Question: Why does the error occurs and how to solve this?</p>