Home Uncategorized Microsoft 365 PowerShell connect to Exchange tenant

Microsoft 365 PowerShell connect to Exchange tenant

35
0

Microsoft has started requiring TLS1.2 and added support for MFA for connections to Exchange tenant using PowerShell. Some of my older instructions are now completely broken so here are new ones:

SETUP: If you haven’t already, you need to install the EXO V2 PowerShell module called ExchangeOnlineManagement.

  • Make sure you’re running the latest PowerShell.
  • Install or Update to the latest PowerShellGet module (needed to connect to the module gallery).
    • You’ll want to update the NuGet provider before the PowerShellGet module.
      Run [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 to ensure you’re using TLS1.2.
      Run Install-PackageProvider -Name NuGet -Force to update NuGet.
    • Run Install-Module -Name PowerShellGet -Force to update PoweShellGet 
  • CLOSE AND REOPEN POWERSHELL
  • Run Install-Module -Name ExchangeOnlineManagement and hope for no errors. If it still isn’t installing then:
  • Run [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
  • Run Register-PSRepository -Default -Verbose
  • Run Install-Module -Name ExchangeOnlineManagement
  • CLOSE AND REOPEN POWERSHELL

You should now see this folder: C:\Program Files (x86)\WindowsPowerShell\Modules\ExchangeOnlineManagement

 

Setup over, let’s connect to the tenant.
“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.”

Follow these instructions to connect:
Connect to Exchange Online PowerShell | Microsoft Docs

Most small biz admins will use Connect-ExchangeOnline -UserPrincipalName navin@contoso.com where the UPN is your admin username.

NOTE: Make sure you close the connection when you’re done: Run Disconnect-ExchangeOnline or else you could use up all your PowerShell sessions and need to wait for old sessions to expire.

LEAVE A REPLY

Please enter your comment!
Please enter your name here