Connect-ExchangeOnline

This cmdlet is available only in the Exchange Online PowerShell V2 module. For more information, see Use the Exchange Online PowerShell V2 module (https://docs.microsoft.com/powershell/exchange/exchange-online/exchange-online-powershell-v2/exchange-online-powershell-v2).

Use the Connect-ExchangeOnline cmdlet in the Exchange Online PowerShell V2 module to connect to an Exchange Online organization.

For information about the parameter sets in the Syntax section below, see Exchange cmdlet syntax (https://docs.microsoft.com/powershell/exchange/exchange-server/exchange-cmdlet-syntax).

Syntax

Connect-ExchangeOnline
       [[-AzureADAuthorizationEndpointUri] <String>]
       [-BypassMailboxAnchoring]
       [[-ConnectionUri] <String>]
       [-Credential <PSCredential>]
       [[-DelegatedOrganization] <String>]
       [-EnableErrorReporting]
       [[-ExchangeEnvironmentName] <ExchangeEnvironment>]
       [-LogDirectoryPath <String>]
       [-PageSize <UInt32>]
       [[-PSSessionOption] <PSSessionOption>]
       [-ShowProgress <Boolean>]
       [-TrackPerformance <Boolean>]
       [-UseMultithreading <Boolean>]
       [-UserPrincipalName <String>]
       [<CommonParameters>]

Description

This cmdlet allows you to create a remote PowerShell connection to your Exchange Online organization. You can use this cmdlet to authenticate for the new REST API-backed cmdlets in the Exchange Online PowerShell V2 module, and also for all existing Exchange Online PowerShell cmdlets (remote PowerShell cmdlets).

Examples

Example 1

$UserCredential = Get-Credential
Connect-ExchangeOnline -Credential $UserCredential

The first command gets the user credentials and stores them in the $Credential variable.

The second command connects the current PowerShell session using the credentials in the $Credential. Note that after the second command is complete, the password key in the $Credential variable becomes empty.

After the Connect-ExchangeOnline command is successful, you can run ExO V2 module cmdlets and older remote PowerShell cmdlets.

Parameters

-AzureADAuthorizationEndpointUri

The AzureADAuthorizationEndpointUri parameter specifies the Azure AD Authorization endpoint Uri that can issue OAuth2 access tokens.

Type:String
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-BypassMailboxAnchoring

The BypassMailboxAnchoring switch bypasses the use of the mailbox anchoring hint. You don't need to specify a value with this switch.

Type:SwitchParameter
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-ConnectionUri

The ConnectionUri parameter specifies the connection endpoint for the remote PowerShell session.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-Credential

The Credential parameter specifies the username and password that's used to run this command. Typically, you use this parameter in scripts or when you need to provide different credentials that have the required permissions.

A value for this parameter requires the Get-Credential cmdlet. To pause this command and receive a prompt for credentials, use the value (Get-Credential). Or, before you run this command, store the credentials in a variable (for example, $cred = Get-Credential) and then use the variable name ($cred) for this parameter. For more information, see Get-Credential.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-DelegatedOrganization

The DelegatedOrganization parameter specifies the domain name of the organization to connect to as a delegated admin (for example, contoso.onmicrosoft.com).

Type:String
Position:5
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-EnableErrorReporting

The EnableErrorReporting switch enables logging errors to a local file. You don't need to specify a value with this switch.

By default, it creates 2 files in the %TMP% folder. You can use the LogDirectoryPath parameter to specify the location of the log files.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-ExchangeEnvironmentName

The ExchangeEnvironmentName specifies the Exchange Online environment. Valid values are:

  • O365China

  • O365Default (this is the default value)

  • O365GermanyCloud

  • O365USGovDoD

  • O365USGovGCCHigh

Type:ExchangeEnvironment
Position:3
Default value:O365Default
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-LogDirectoryPath

The LogDirectoryPath parameter specifies the location of telemetry data. The default location is %TMP%\EXOCmdletTelemetry\EXOCmdletTelemetry-yyyymmdd-hhmmss.csv.

If you specify a custom location and filename that contains spaces, enclose the value in quotation marks (").

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-PSSessionOption

The PSSessionOption parameter specifies the PowerShell session options to use in your connection to Exchange Online. You store the output of the New-PSSessionOption command in a variable (for example, $Options = New-PSSessionOption <Settings>), and you use the variable name as the value for this parameter (for example, $Options).

Type:PSSessionOption
Position:4
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-PageSize

The PageSize parameter specifies the maximum number of entries per page. Valid input for this parameter is an integer between 1 and 5000. The default value is 1000.

Type:UInt32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-ShowProgress

The ShowProgress parameter shows a visual progress bar in the PowerShell client module. The progress bar shows number of objects received and total number of objects requested. Valid values are:

  • $true: The progress bar is displayed.

  • $false: The progress bar isn't displayed.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-TrackPerformance

{{ Fill TrackPerformance Description }}

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-UseMultithreading

The UseMultithreading parameter specifies whether to disable or enable multi-threading in the EXO V2 module Valid values are:

  • $true: Enable multi-threading. This is the default value.

  • $false: Disable multi-threading. Note this value will degrade performance of V2 cmdlets.

Type:Boolean
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online
-UserPrincipalName

The UserPrincipalName parameter specifies the account that you want to use to connect (for example, navin@contoso.onmicrosoft.com). Using this parameter allows you to skip the first screen in authentication prompt.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:Exchange Online

Inputs

Outputs