Connect to Exchange online powershell

Connect to Exchange Online powershell

  • Run Powershell as administrator


  • Copy paste the below commands and enter credentials when prompted

$cloudcred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cloudCred -Authentication Basic -AllowRedirection
Import-PSSession $Session

  • Alternatively you can save above commands in a file as .ps1 and execute it on the powershell window

  • The newer powershell module Exchange PowerShell V2 allows you to connect directly using below command and also support MFA.
Connect-EXOPSSession -UserPrincipalName "your UPN"


use can connect to Azure Active directory and Exchange online by running the following commands (by just add two line to the above one)

import-module msonline
$cloudcred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cloudCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Connect-MsolService -Credential $cloudcred

The newer module of AzureAD is available and can be connected through the below

Connect-AzureAD -Credential $cloudcred




Comments

Popular posts from this blog

Clearing Exchange online mailbox purge, dumpster folder

create AD contacts, Bulk create AD contacts - Active Directory PowerShell

Add description to AD contact and bulk add description for contacts - Active Directory PowerShell