Site icon Welcome Admin

How-to: Connect to Exchange Online PowerShell | Step-by-Step

Connect-to-Exchange-Online-PowerShell

Let’s get started To Connect to Exchange Online PowerShell

Prerequisites for the Exchange Online PowerShell module

There are two main sets of prerequisites for using the Exchange Online PowerShell module:

Software and System:

To check your current power-shell installed in system try any of below methods

#Method 1
host
#Method 2
$PSVersionTable
#Method 3
$PSVersionTable.PSVersion.major
#Method 4
$PSVersionTable.PSVersion
# Get installed .NET Framework versions
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
Get-ItemProperty -Name Version -EA 0 |
Where { $_.PSChildName -Match '^(?!S)\p{L}'} |
Select PSChildName, Version

Permissions and Access:

Additional notes:

Set-ExecutionPolicy RemoteSigned

Step 1: Install Exchange Online PowerShell module

Get-InstalledModule -Name ExchangeOnlineManagement
Install-Module -Name ExchangeOnlineManagement
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
Get-InstalledModule -Name ExchangeOnlineManagement
#Or
Get-Module -ListAvailable | Where-Object {$_.Name -like "ExchangeOnline*"}

More info About the Exchange Online PowerShell module

Step 2: Update Exchange Online PowerShell Module

Update-Module ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement; Get-Module ExchangeOnlineManagement

Step 3: Connect with an interactive login prompt

Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName YourUsername@Yourdomain.com

Now, if we try to execute the module load or connect command without executing the ‘Set-ExecutionPolicy RemoteSigned‘ command mentioned in the prerequisites, we will face a failure above

But If we have already executed it, the module will be loaded and connected successfully

Step 4: Disconnect when you’re finished

Be sure to disconnect the session when you’re finished. If you close the PowerShell window without disconnecting the session, you could use up all the sessions available to you, and you need to wait for the sessions to expire. To disconnect the session, run the following command:

Disconnect-ExchangeOnline

To silently disconnect without a confirmation prompt, run the following command:

Disconnect-ExchangeOnline -Confirm:$false

Helpful Resources:

Thanks for reading and follow us

Exit mobile version