title: How to close every interactive PowerShell session?
body: <p>Is there a way to exit every interactive PowerShell session created by <code>Enter-PSSession</code> in PowerShell?</p>
  
  <p>I tried something like
  :</p>
  
  <pre class="lang-bsh prettyprint-override"><code>Get-PSSession -ComputerName $computerName -Credential $credential | Exit-PSSession
  </code></pre>
  
  <p>or </p>
  
  <pre class="lang-bsh prettyprint-override"><code>Get-PSSession -ComputerName "pp1KYCiis01" -Credential eperret@vppp.local | foreach { Exit-PSSession $_ }
  </code></pre>
  
  <p>But does not seem to be right...</p>
  
  <pre class="lang-bsh prettyprint-override"><code>Exit-PSSession : The input object cannot be bound to any parameters for the command either because the command does not take
  pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
  [...]
  </code></pre>
  
  <p>Example of <code>Get-PSSession</code>:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>PS C:\Users\eperret&gt; Get-PSSession -ComputerName $computerName -Credential $credential
  
   Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
   -- ----            ------------    ------------    -----         -----------------     ------------
   36 WinRM7          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   37 WinRM4          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   38 WinRM2          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   39 WinRM5          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   40 WinRM3          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
  </code></pre>
  
  <p>and piping <code>Disconnect-PSSession</code>...</p>
  
  <pre class="lang-bsh prettyprint-override"><code>PS C:\Users\eperret&gt; Get-PSSession -ComputerName $computerName -Credential $credential | Disconnect-PSSession
  
   Id Name            ComputerName    ComputerType    State         ConfigurationName     Availability
   -- ----            ------------    ------------    -----         -----------------     ------------
   46 WinRM7          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   47 WinRM4          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   48 WinRM2          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   49 WinRM5          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
   50 WinRM3          computerNam     RemoteMachine   Disconnected  Microsoft.PowerShell          Busy
  </code></pre>