Skip to main content
Version: Next

Connect and disconnect from Microsoft 365

For full details and examples, run Get-Help <FunctionName> -Detailed or -Examples.

Connect-EOL​

Connect to Exchange Online (EXO V3), auto-importing the module and auto-detecting the current user when -UserPrincipalName is not supplied. By default it tries the standard interactive sign-in flow with WAM. This matters because WAM became the default Exchange Online auth path starting with ExchangeOnlineManagement 3.7.0. If the EXO module fails with a WAM/MSAL broker error, Nebula automatically retries with -DisableWAM.

Connect-ExchangeOnline's own cosmetic "Sign in by Web Account Manager (WAM) is enabled by default" notice is hidden on every call unless you pass -Verbose — useful when diagnosing WAM/broker issues, otherwise just noise repeated on every sign-in.

Syntax

Connect-EOL [-UserPrincipalName <String>] [-DelegatedOrganization <String>] [-DisableWAM] [-Device]
[-NoWamFallback] [-PassThru]
ParameterTypeDescriptionRequiredDefault
UserPrincipalName (UPN, User)StringUPN/e-mail for the EXO auth prompt.NoCurrent user (Find-UserConnected)
DelegatedOrganizationStringTarget customer tenant (delegated admin).No-
DisableWAMSwitchDisable Web Account Manager (WAM) for EXO sign-in.NoFalse
DeviceSwitchUse device-code auth for EXO.NoFalse
NoWamFallbackSwitchDo not auto-retry with -DisableWAM if the WAM flow fails.NoFalse
PassThruSwitchReturn the Connect-ExchangeOnline session object.NoFalse

Example

Connect-EOL -UserPrincipalName 'admin@contoso.com'
# Useful after Windows lock/sleep or when EXO fails in RuntimeBroker / WAM
Connect-EOL -DisableWAM
# Browserless fallback in PowerShell 7+
Connect-EOL -DisableWAM -Device
Pinned pre-3.7.2 ExchangeOnlineManagement

-DisableWAM and -Device only exist on Connect-ExchangeOnline starting with ExchangeOnlineManagement 3.7.2 (the release that made WAM the default). If you've intentionally pinned an older version as a workaround for the Graph/EOL assembly clash, Connect-EOL detects this and silently ignores -DisableWAM (nothing to disable) or warns and falls back to the standard interactive flow for -Device, instead of failing with a parameter-binding error.

Connect-Nebula​

One-shot helper that connects Microsoft Graph first and then Exchange Online with WAM disabled. The order and EXO authentication mode are intentional: they let Graph load its dependencies before Exchange Online and avoid the known cross-module assembly and broker conflict. Use -SkipGraph when only an EXO session is required and you want the normal EXO WAM flow.

Syntax

Connect-Nebula [-UserPrincipalName <String>] [-GraphScopes <String[]>] [-GraphTenantId <String>]
[-GraphDeviceCode] [-GraphLoginHint <String>] [-AutoInstall] [-ForceReconnect] [-SkipGraph]
ParameterTypeDescriptionRequiredDefault
UserPrincipalNameStringUPN for EXO auth.NoAuto-detected
GraphScopesString[]Graph delegated scopes to request.NoUser.Read.All
GraphTenantIdStringTenant ID/domain for Graph.No-
GraphDeviceCodeSwitchUse device code instead of browser for Graph.NoFalse
GraphLoginHintStringUPN passed as -LoginHint to Connect-MgGraph, so the WAM broker can resolve the target account without repeated prompts. Without it and without -UserPrincipalName, an active Graph session keeps its own account; otherwise the Windows identity is used. Needs Microsoft.Graph.Authentication 2.39.0 or later; older versions sign in without the hint.NoUserPrincipalName
AutoInstallSwitchAuto-install missing modules.NoFalse
ForceReconnectSwitchSkip health checks and reconnect both services.NoFalse
SkipGraphSwitchConnect only EXO, skip Graph entirely.NoFalse

Example

Connect-Nebula -GraphScopes 'User.Read.All','Directory.Read.All' -AutoInstall
Repeated Graph auth prompts during bulk operations

If a healthy, already-connected Graph session keeps popping a WAM account-picker on individual delegated Graph operations (for example, running many license or group changes in a loop), this is related WAM broker friction from the known Exchange Online/Graph assembly clash, not a normal re-auth. -GraphDeviceCode is not a reliable workaround for it — in practice it can fail with Authentication timed out after 120 seconds due to inactivity instead of prompting a code. Close every PowerShell window (not just disconnect) and re-run plain Connect-Nebula in a fresh process instead. Since 1.3.0, Nebula.Core bulk functions send Microsoft Graph requests in batches of 20, so when this happens you get at most one prompt per batch instead of one per item. See Exchange Online and Microsoft Graph PowerShell assembly clash for background and unattended/bulk-script alternatives (app-only certificate auth).

Automatic update function

By default, Connect-Nebula checks PowerShell Gallery for updates of Nebula.* modules plus the meta modules ExchangeOnlineManagement and Microsoft.Graph, warning only when updates are available. Disable it by setting CheckUpdatesOnConnect = $false in your settings.psd1 and then run Sync-NebulaConfig. You can also throttle checks by setting CheckUpdatesIntervalHours (default is 72). Run Get-NebulaModuleUpdates anytime to trigger a manual check.

Disconnect-Nebula​

Disconnect EXO and/or Graph.

Syntax

Disconnect-Nebula [-ExchangeOnly] [-GraphOnly]
ParameterTypeDescriptionRequiredDefault
ExchangeOnlySwitchDisconnect only EXO.NoFalse
GraphOnlySwitchDisconnect only Graph.NoFalse

Example

Disconnect-Nebula -GraphOnly # keep EXO session alive
tip

Leave-Nebula is an alias for Disconnect-Nebula.

Get-NebulaConnections​

Show current Nebula connection status for Exchange Online and Microsoft Graph. By default it runs lightweight health probes (unless -SkipHealthCheck) which can also refresh provider-side sessions/tokens.

Syntax

Get-NebulaConnections [-SkipHealthCheck]
ParameterTypeDescriptionRequiredDefault
SkipHealthCheckSwitchSkip the health probes and only report whether session contexts are present.NoFalse

Update-NebulaConnections​

Explicit refresh entry point for connection status checks. It runs the same health probes as Get-NebulaConnections and, unless -SkipHealthCheck is used, reconnects any service found disconnected or unhealthy (stale/broken session), reusing the account each session already uses (falling back to the detected Windows identity when there is no session) and, for Microsoft Graph, the scopes already granted to the current session. Use it when your intent is to "refresh/revive" current sessions.

Syntax

Update-NebulaConnections [-SkipHealthCheck]
ParameterTypeDescriptionRequiredDefault
SkipHealthCheckSwitchSkip probe and repair entirely and only report whether session contexts are present.NoFalse

Returned properties

PropertyDescription
ExchangeOnlineConnectedTrue when an EXO session is active.
ExchangeOnlineHealthyTrue when a lightweight EXO probe succeeds (session really usable).
ExchangeOnlineErrorLast EXO validation error (if any).
ExchangeOnlineUserConnected EXO user (when available).
ExchangeOnlineTenantConnected EXO organization/tenant (when available).
MicrosoftGraphConnectedTrue when a Graph context is active.
MicrosoftGraphHealthyTrue when a lightweight Graph probe succeeds (token really usable).
MicrosoftGraphErrorLast Graph validation error (if any).
MicrosoftGraphAccountConnected Graph account (when available).
MicrosoftGraphTenantIdConnected Graph tenant ID (when available).
MicrosoftGraphScopesScopes present in the active Graph context.

Example

Connect-Nebula
Update-NebulaConnections
Leave-Nebula

Questions and answers​

Which services does Connect-Nebula connect?​

Exchange Online always; Microsoft Graph unless you use -SkipGraph. Default Graph scopes include User.Read.All (extend with -GraphScopes).

Can I operate across multiple tenants?​

Yes. Use Connect-EOL -DelegatedOrganization for delegated tenants and Connect-Nebula -GraphTenantId for Graph. Run Disconnect-Nebula before switching contexts.

How can I check active sessions before disconnecting?​

Run Update-NebulaConnections (or Get-NebulaConnections) and verify ExchangeOnlineConnected / MicrosoftGraphConnected are True or False. For real usability checks after long idle periods, prefer ExchangeOnlineHealthy / MicrosoftGraphHealthy.

What happens if Exchange Online auth breaks after a Windows lock or idle period?​

When using Connect-Nebula, Microsoft Graph is initialized first and the subsequent EXO login uses -DisableWAM, so the Graph/EXO authentication modules do not clash in the same PowerShell process. Direct Connect-EOL calls still try the normal WAM-based login first (WAM is the default starting with ExchangeOnlineManagement 3.7.0) and retry with -DisableWAM when the broker reports a recognized WAM/MSAL error.

If you want to bypass WAM immediately, use:

Connect-EOL -DisableWAM

or, in PowerShell 7+:

Connect-EOL -DisableWAM -Device