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)
    *.teams.microsoft.com, login.microsoftonline.com
  • 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

IT Consultant Specialties: Remote Desktop Services, Office 365, User Profile and Group Policy Management

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

  • 23. May 2019 at 12:25
    Permalink

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

    Reply
  • 4. August 2019 at 14:30
    Permalink

    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?

    Reply
    • 5. August 2019 at 19:17
      Permalink

      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

      Reply

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.