Skip to content

Instantly share code, notes, and snippets.

@jforet1
Created September 16, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jforet1/78eaa80136e31549346586a61dc9b949 to your computer and use it in GitHub Desktop.
Save jforet1/78eaa80136e31549346586a61dc9b949 to your computer and use it in GitHub Desktop.
Exchange Online PowerShell - MFA Timeout Fix
$username = "replaceme@contoso.com"
Connect-ExchangeOnline -UserPrincipalName $username
$mailboxes = Get-Mailbox -ResultSize:unlimited -Filter "RecipientTypeDetails -eq 'UserMailbox'"
$mailboxes | ForEach-Object {
$connectionstatus = Get-PSSession | Where-Object {$_.ConfigurationName -like "Microsoft.Exchange"}
if ($connectionstatus.State -ne "Opened") {
Connect-ExchangeOnline -UserPrincipalName $username
}
#do stuff here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment