Microsoft Teams Authentication Problems – Workaround PowerShell Script

The Problem

After a Domain Password change, my Teams Desktop Client was stuck in an Authentication Loop. I tried several things for troubleshooting, but the single steps didn’t solve the problem for itself. As a normal User, I would open a Helpdesk Ticket and would wait until they solve the problem for me. But as a System Engineer and Teams Consultant, I should find the problem by myself, I thought. And yes I tried to turn it of and on again and it didn’t help ;-).

BTW: It seems that I’m not alone with this problem because on UserVoice several reported and upvoted it.

The Solution

As a result, I tried all troubleshooting steps together and that finally solved my authentication problems.

  • Make the Internet Explorer Site to Zone Assignments for Microsoft Teams (Trusted Sites)
  • Purge the Microsoft Teams Client Cache Folders
  • Clear the Cached Credentials for Microsoft Teams

Finally, my problem was solved and I did not disturb our Helpdesk Team.

Automated the solution with a PowerShell Script

But the troubleshooting took me an hour and manually deleting multiple entries from Windows Credential Manager is not my favorite job. So I used my spare time on Sunday, Yes I’m a Nerd!, and wrote a PowerShell Script for it.

Feel free to try it out, and comment here in the Blog, or at Twitter @philipp_kohn if you have suggestions for optimizing the Script. Reminder: No Backup no mercy! – Use my Scripts at your own Risk 😀

Philipp Kohn

Consultant for Modern Workplace & Cloud Computing. Especially interested in Microsoft 365 & Digital Transformation. - If you are afraid you cannot innovate! -

7 thoughts on “Microsoft Teams Authentication Problems – Workaround PowerShell Script

  • 23. May 2019 at 12:25

    your script was exactly what I needed, is there anyway you can do the same for yammer 🙂

  • 4. August 2019 at 14:30

    Hey Philipp! I’m having trouble with the script’s “Else” part

    ELSE : The term ‘ELSE’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + ELSE {New-ItemProperty -Path $registryPath2 -Name $name2 -Value $v …
    + ~~~~
    + CategoryInfo : ObjectNotFound: (ELSE:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Although all the prompts came up clearing the cache and credentials, etc. Any suggestions?

    • 5. August 2019 at 19:17

      Hi Ash,

      I tried the script and copied it, from this blog article directly to an open ISE Session.
      It worked for me with no errors can you double-check that you have copied it exactly. Btw what’s your OS language, only tested it successfully with an “EN-US” Windows 10 1903.

      PS C:\WINDOWS\System32> . 'C:\Scripts\O365\Untitled2.ps1' <# script is not saved yet #>
      WARNING: Script stops all running Teams processes in 15 seconds! Press Ctrl+C to stop script processing

      CMDKEY: Credential deleted successfully.
      CMDKEY: Credential deleted successfully.

      Regards Philipp

  • 4. September 2019 at 18:12

    I solved the problem with Microsoft Teams Client deleting the credentials starting with “msteams_adalsso …” in the windows credential manager.

    After, delete all contents of the following folder:
    C:\Users\\Dados de Aplicativos\Microsoft\Teams

  • 9. September 2019 at 12:09

    Thank you! This solved my problem. As for the error:
    When running the script in Windows PowerShell as admin it fails but when running it as admin in Windows PowerShell ISE it works like charm.

    • 9. September 2019 at 17:31

      Happy that I could help.

      I will edit the description with a little How-To soon. Thx for the feedback.

      Regards Philipp

  • 16. September 2019 at 10:54

    What worked for me was to quit the desktop client and login via the web client. This sent me through the normal login journey and logged me in. I could then open the Desktop client. No special powershell magic required.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.