Created
September 16, 2020 14:18
-
-
Save jforet1/78eaa80136e31549346586a61dc9b949 to your computer and use it in GitHub Desktop.
Exchange Online PowerShell - MFA Timeout Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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