Skip to content

Instantly share code, notes, and snippets.

@OlafD
Last active January 11, 2024 12:51
Show Gist options
  • Save OlafD/95caa302a89155c065b559df68deda8b to your computer and use it in GitHub Desktop.
Save OlafD/95caa302a89155c065b559df68deda8b to your computer and use it in GitHub Desktop.
Connect to Office 365 Exchange Online with PowerShell
if ($cred -eq $null)
{
$cred = Get-Credential
}
Write-Host "Connecting to Exchange Online"
$exchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $exchangeSession | Out-Null
Write-Host "Connected to Exchange Online"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment