Connect To Exchange Online PowerShell EXO V2

The Exchange Online PowerShell V2 module (abbreviated as the EXO V2 module) uses modern authentication and works with multi-factor authentication (MFA) for connecting to all Exchange-related PowerShell environments in Microsoft 365: Exchange Online PowerShell, Security & Compliance PowerShell, and standalone Exchange Online Protection (EOP) PowerShell.

 

using modern authentication:

 

Prerequisites

  • Windows PowerShell needs to be configured to run scripts, and by default, it isn’t. You’ll get the following error when you try to connect: “Files cannot be loaded because running scripts is disabled on this system. Provide a valid certificate with which to sign the files”.
  • run the following command in an elevated Windows PowerShell (Run As Administrator)

       Set-ExecutionPolicy RemoteSigned

  • WinRM needs to allow Basic authentication

   To verify that Basic authentication is enabled for WinRM, run this 

   command in a Command Prompt (not in Windows PowerShell):

         winrm get winrm/config/client/auth

   If you don’t see the value Basic = true, you need to run this command in a    Command Prompt (not in Windows PowerShell) to enable Basic authentication        for WinRM:

         winrm set winrm/config/client/auth @{Basic=”true”}

 INSTALL EXO V2 Module

  • Install or update the PowerShellGet module 

      Install-Module -Name PowerShellGet -Force // PS 5

      Install-PackageProvider -Name NuGet -Force // PS 4

  • Install the EXO 

       Install-Module -Name ExchangeOnlineManagement

Connect to Exchange Online PowerShell using MFA and modern authentication

For MFA authentication Run :

Import-Module ExchangeOnlineManagement

Connect-ExchangeOnline -UserPrincipalName

Connect to Exchange Online PowerShell using modern authentication

For Modern Only authentication Run :

Import-Module ExchangeOnlineManagement

$UserCredential = Get-Credential

Connect-ExchangeOnline -Credential $UserCredential

SHMUEL H.

Leave a Reply

Discover more from Rafael IT Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading