In order manage your Exchange Online (M365), you need to first connect to your M365 using you Windows PowerShell. After searching multiple blogs and applying multiple scripts, I found the below working seamless for me.
Module: ExchangePowerShell
Applies to: Exchange Online
Connect Exchange Online using Windows PowerShell.
- From the Windows PowerShell elevated prompt.
$UserCredential = Get-Credential
- Enter the M365 Global Admin credentials
- Run Connect-IPPSSession -Credential $UserCredential
Use the Connect-IPPSSession cmdlet in the Exchange Online PowerShell V2 module to connect to Security & Compliance Center PowerShell or standalone Exchange Online Protection PowerShell using modern authentication. The cmdlet works for MFA or non-MFA enabled accounts.
- Run Connect-ExchangeOnline -Credential $UserCredential
Use the Connect-ExchangeOnline cmdlet in the Exchange Online PowerShell V2 module to connect to Exchange Online PowerShell using modern authentication. This cmdlet works for MFA or non-MFA enabled accounts.
If you face an error in step number 4, you will have to Install EXO V2 module. It is just one single command Install-Module -Name ExchangeOnlineManagement
For Connecting Exchange Online you will have to Install and maintain the EXO V2 module.
You can download the EXO V2 module from the PowerShell gallery at https://www.powershellgallery.com/packages/ExchangeOnlineManagement/
Refer the below snapshot for steps that I had performed to connect my M365 Portal successfully.