Skip to main content

Connect (and disconnects) to/from Microsoft 365

For full, always-up-to-date details and examples, use 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.

Syntax

Connect-EOL [-UserPrincipalName <String>] [-DelegatedOrganization <String>] [-PassThru]
ParameterTypeDescriptionRequiredDefault
UserPrincipalNameStringUPN/e-mail for the EXO auth prompt.NoCurrent user (Find-UserConnected)
DelegatedOrganizationStringTarget customer tenant (delegated admin).No-
PassThruSwitchReturn the Connect-ExchangeOnline session object.NoFalse

Example

Connect-EOL -UserPrincipalName 'admin@contoso.com'

Connect-Nebula

One-shot helper that ensures EXO is connected, then (optionally) connects Microsoft Graph.

Syntax

Connect-Nebula [-UserPrincipalName <String>] [-GraphScopes <String[]>] [-GraphTenantId <String>]
[-GraphDeviceCode] [-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
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
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 24). 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]

Update-NebulaConnections

Explicit refresh entry point for connection status checks. It runs the same checks as Get-NebulaConnections and is preferred when your intent is to "refresh/revive" current sessions.

Syntax

Update-NebulaConnections [-SkipHealthCheck]

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.