Advertisement
AutomateMyStuff

Powershell - O365 Cleanup Sessions On Exit

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