Get-Ryan

Exchange PSSession cleanup on exit

Oct 7th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Register-EngineEvent PowerShell.Exiting -SupportEvent -Action {
  2.  
  3.     $Session = Get-PSSession | Where-Object {$_.ConfigurationName -like "Microsoft.Exchange"}
  4.     ForEach($obj in $Session){
  5.         Remove-PSSession $obj
  6.     }
  7. }
Advertisement
Add Comment
Please, Sign In to add comment