How to Fix Office365/Outlook login loop when using MFA
top of page

How to Fix Office365/Outlook login loop when using MFA



I've come across this issue many times in the past several years where Outlook or another Office application (Word, Excel, etc.) will continuously prompt the user to login over and over again. This usually happens when multi-factor authentication is enabled with the O365 account (which should be standard these days).


Step 1 - Sign out of the Work or School Account

The first things I would try is to sign the user out of their work or school account from the Windows settings.


1. Go to Windows Settings and then Accounts

2. Click on "Access work or school" on the left and then on the account with the Windows logo.

3. Then click on "Disconnect"

4. Try to sign into Outlook and see if it works. If not, proceed to Step 2.


Step 2 - Powershell script to clear the cached credentials


If Step 1 didn't work, then clearing the cached credentials should fix the issue. NOTE: You will need local admin permissions on the computer. This Powershell script will delete the cached credentials in the user's profile folder.



# Require elevation
$isAdmin=[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")
if (-not $isAdmin)
{
    Start-Process powershell.exe "-File `"$PSCommandPath`"" -Verb RunAs
    exit
}

#Get the current user's information
$User = ((Get-WMIObject -ClassName Win32_ComputerSystem).Username).Split('\')[1]

#Get the location of the cached credentials and then delete them
Get-ItemProperty -Path "C:\Users\$user\AppData\Local\Packages" | ForEach-Object {
Remove-Item -Path "$_\Microsoft.AAD.BrokerPlugin*" -Recurse -Force | Out-Null
}

#Display the following lines on screen
Write-Host
Write-Host "The Office365 cached credentials have been cleared." -ForegroundColor Green
Write-Host
Write-Host "The computer needs to be rebooted." -ForegroundColor Magenta
Write-Host

#Prompt for computer reboot
while ($true) {
    $choice = Read-Host "Do you want to reboot the computer now? (Y/N)"

    if ($choice -eq "Y") {
        Restart-Computer -Force
        break
    }
    elseif ($choice -eq "N") {
        Write-Host "Reboot postponed. Exiting script."
        break
    }
    else {
        Write-Host "Invalid input. Please try again."
    }
}

Copy the above code into a text file or download the file below and rename the extension to .ps1

ForceO365SignOut v1.1
.txt
Download TXT • 1KB

1. Save it to a folder on the user's computer that's having the issue and then right-click and choose "Run with Powershell"


2. Enter the local administrator creds when prompted

3. Then choose to reboot immediately or wait until later.

4. Once the computer reboots, have them sign into Outlook/Office 365.








196 views0 comments
bottom of page