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-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]
ParameterDescriptionRequiredDefault
UserPrincipalNameUPN for EXO auth.NoAuto-detected
GraphScopesGraph delegated scopes to request.NoUser.Read.All
GraphTenantIdTenant ID/domain for Graph.No-
GraphDeviceCodeUse device code instead of browser for Graph.NoFalse
AutoInstallAuto-install missing modules.NoFalse
ForceReconnectSkip health checks and reconnect both services.NoFalse
SkipGraphConnect only EXO, skip Graph entirely.NoFalse

Example

Connect-Nebula -GraphScopes 'User.Read.All','Directory.Read.All' -AutoInstall

Disconnect-Nebula

Disconnect EXO and/or Graph.

Syntax

Disconnect-Nebula [-ExchangeOnly] [-GraphOnly]
ParameterDescriptionDefault
ExchangeOnlyDisconnect only EXO.False
GraphOnlyDisconnect only Graph.False

Example

Disconnect-Nebula -GraphOnly   # keep EXO session alive

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]
ParameterDescriptionRequiredDefault
UserPrincipalNameUPN/e-mail for the EXO auth prompt.NoCurrent user (Find-UserConnected)
DelegatedOrganizationTarget customer tenant (delegated admin).No-
PassThruReturn the Connect-ExchangeOnline session object.NoFalse

Example

Connect-EOL -UserPrincipalName 'admin@tenant.onmicrosoft.com'

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.