Remove-MapiSession

Description

This cmdlet is used to remove and logoff from an existing MAPI Session.

Syntax
Note: Parameters in orange are optional.
Remove-MapiSession
-SessionMapiObject<Mapi.NET.Session>
Remove-MapiSession
-ProfileNameString
Remove-MapiSession
-IndexSystem.Int32
Parameters
SessionA Mapi.NET.Session object of which to logoff and remove from the internal session list.
ProfileNameA text string that is the name of the MAPI profile for which an existing Session was opened.
IndexA System.Int32 value that is the specific session in from the internal session list (see Get-MapiSession) to be removed.
Remarks

 

A MAPI session is the main entry point for operations with MAPI and Exchange data.  MAPI sessions consume memory and CPU cycles while open and should be removed when no longer needed.

PowerMAPI maintains an internal list of opened sessions (see Get-MapiSession).  This cmdlet performs a MAPI logoff procedure followed by a removal from the internal list.  If the PowerShell session hosting PowerMAPI is closed unexpectedly, the MAPI sessions may become orphaned and may leak memory or maintain file or network locks on resources.  PowerMAPI makes every attempt to cleanly logoff sessions when PowerShell is unloaded, but application crashes, host reboots, and the like can cause such logoff actions to fail to occur.