New-MapiSession

Description

This cmdlet creates and connects to a new MAPI session.

Syntax
Note: Parameters in orange are optional.
New-MapiSession
-ProfileString
-CredentialsPSCredential
Parameters
ProfileA text string that is the name of the MAPI profile to open in a new session.
CredentialsAn optional PSCredential object that can be used to inline authenticate when opening a profile.
Remarks

This cmdlet creates and opens a new MAPI session for the specified profile, or for a shared session.

If the Profile parameter is omitted, the cmdlet opens a MAPI shared session.  A shared session is one that is opened against an already opened session.  For example, if Outlook is already open, a shared session can be opened to access the same session that Outlook is currently using.

However, be aware that if multiple applications have opened multiple profiles concurrently, the "shared" session becomes a bit ambiguous and generally is the first MAPI session created.

The Credentials parameter allows for the inline authentication of a profile.  In many cases, and especially when working with profiles that connect to Exchange or Office365 mailboxes, credentials are required to access the mailbox configured.  If a MAPI profile normally prompts for credentials, PowerMAPI can suppress the prompt and pass the credentials inline.  This is especially helpful for script writers that may need to open a series of mailboxes for some action.

Note that PowerMAPI is not managing or manipulating windows Credential Vault to provide this feature; saved usernames and passwords in Windows are not read nor modified with this feature.