MS Teams logout issue

Copper Contributor

I am trying to figure out an issue with MS Teams, and not having much luck, so I'm wondering if anyone else has encountered this before.


We have a shared PC in a conference room that people will use to log into a shared user account, and then into their personal Teams account during their meeting. The problem is that some users' accounts seem to be cached on the PC, and all you need to do to log into their account is enter their email, no password required.


I have tried the following, with no luck so far:

  • Completely cleared out credential manager
  • Deleted the contents of %AppData%\Microsoft\Teams
  • Deleted the contents of HKLM\Software\Microsoft\Office\Teams
  • Uninstall/reinstall with Revo Uninstaller to also remove leftover registry/folder items


I finally reimaged the computer I was testing on, which of course fixed the issue, but there has to be a less invasive solution that I just haven't found yet.


Thanks in advance.

27 Replies

@awarwick Hello, you can prevent the pre-population of the UPN with a registry key.


0x00000001 (1)

@ChristianBergstrom This does not actually solve the problem I mentioned, it only prevents Teams from auto-populating the username.


Through a little bit more testing, I've narrowed it down a little farther.  It as long as I click on "No, sign in to this app only" on the attached image, my login is not remembered and I need to enter a password every time I log in.  However, as soon as I click OK in this window, whether the "Allow my organization to manage my device" checkbox is checked or not, my password is saved on this Teams login going forward, and there's no way to reverse it short of fully reimaging the computer (at least that I have found so far).  And until I reimage the PC, anyone can log into my Teams account using only my email address, no password required.


Also note that this is related to our conference room PCs, which use a shared Windows login, so I'm guessing you might not have this issue without shared logins, I just haven't tested that yet since it wouldn't really help our specific scenario.

@awarwick Hi, just to be clear as this hasn't been mentioned. Are these users manually signing out from  Teams as well? (top right corner). Teams uses modern authentication and the process and different scenarios such as MFA, domain-joined or not etc. are being described in the previous link I attached. Perhaps this is already taken into consideration but need to ask.


That's correct.  The users will use the logout option in the menu at the top left, but when they go to sign in again, they enter their username, click next, and then are signed in without a password.  This behaves the same way after a reboot as well.


The PC is domain joined, and we are starting to implement MFA, but this issue existed before any of our users were setup with MFA.


The link in your first response didn't really help.  It seems to describe how it's supposed to work, and by their description it sounds like using the logout function should cause Teams to prompt for a password again, but that's not what we are seeing here.  Where I am at so far, even after using the logout function, the PC will never ask for a password for that account again, until the PC is fully reimaged.

Do they have to use the desktop app? Whats the purpose of the shared computers? Looked at Teams Rooms? (on mobile so being brief).


I have an issue with the MS Team login.

I have 2 account

1. From IT Team

2. Reigning Champs

on the same email. I have successfully login into both accounts. But whenever my system restart. Champs accounts are not opening. It is giving an error. But IT account always open in the MS team.

I have cleared data

Clear MS Team Cache:
%AppData%\Microsoft\teams\application cache\cache
%AppData%\Microsoft\teams\Local Storage
%LocalAppData%\Google\Chrome\User Data\Default\Cache
%LocalAppData%\Google\Chrome\User Data\Default\Cookies
%LocalAppData%\Google\Chrome\User Data\Default\Web Data

But there is going to the same account to champs account.

when un-install then it will work but sometimes is not work. My local system is working fine. but the office system is not working.



I didn't find any correct solutions also there are not correct solutions every time un-install the MS team.

Very bad experience with MS team. I think I will not refer to this. there it, not any clear cache to clear the account and go to Champs account.

Sorry about that


Rajput Vikash Rana



try this powershell script:

#Stop Teams process 
Get-Process -ProcessName Teams -ErrorAction SilentlyContinue | Stop-Process -Force 
Start-Sleep -Seconds 3
Write-Host "Teams Process Sucessfully Stopped" 

#Clear Team Cache
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\blob_storage" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\databases" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\cache" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\gpucache" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Indexeddb" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\Local Storage" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $env:APPDATA\"Microsoft\teams\tmp" | Remove-Item -Recurse -ErrorAction SilentlyContinue
Write-Host "Teams Cache Cleaned" 
echo $_ 

#Remove Credential from Credential manager
$credential = cmdkey /list | ForEach-Object{if($_ -like "*Target:*" -and $_ -like "*msteams*"){cmdkey /del:($_ -replace " ","" -replace "Target:","")}}

#Remove Reg.Key
$Regkeypath= "HKCU:\Software\Microsoft\Office\Teams" 
$value = (Get-ItemProperty $Regkeypath).HomeUserUpn -eq $null
If ($value -eq $False) 
  Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Office\Teams" -Name "HomeUserUpn"
  Write-Host "The registry value Sucessfully removed" 
Else { Write-Host "The registry value does not exist"}

#Get Desktop-config.json
$TeamsFolders = "$env:APPDATA\Microsoft\teams"
$SourceDesktopConfigFile = "$TeamsFolders\desktop-config.json"
$desktopConfig = (Get-Content -Path $SourceDesktopConfigFile | ConvertFrom-Json)
catch{ Write-Host "Failed to open Desktop-config.json" }

#Overwrite the desktop-config.json
Write-Host "Modify desktop-Config.Json"
$desktopConfig.isLoggedOut = $true
$desktopConfig.upnWindowUserUpn =""; #The email used to sign in
$desktopConfig.userUpn ="";
$desktopConfig.userOid ="";
$desktopConfig.userTid = "";
$desktopConfig.homeTenantId ="";
$desktopConfig | ConvertTo-Json -Compress | Set-Content -Path $SourceDesktopConfigFile -Force
catch{ Write-Host "Failed to overwrite desktop-config.json" }
Write-Host "Modify desktop-Config.Json - Finished"

#Lastly delete the storage.json, this corrects some error that MSTeams otherwise would have when logging in again.
Get-ChildItem "$TeamsFolders\storage.json" | Remove-Item




Dear awarwick,


thank you for already bringing up this issue. I just stumbled on the same problem, as we use a shared laptop in our university group for teaching activities. As you already pointed out, the critical point is whether you accept or decline to let your company manage your account while logging in for the first time in Microsoft Teams Desktop. After accepting this option I failed in a similar way to log out. I am a bit surprised that Microsoft does not provide an intuitive way to resolve this issue already in Teams or the login window.


I am not a specialist, but could resolve the issue for me in the following way (...after some time):

Click "Start" -> click "Settings -> click "Accounts" -> choose "Access work or school". There you can delete your account from the system.


Best regards,


it works, If the users have enough rights
this is a risk for us if the users do not do this, so we use the logoff script
I appreciate Your efforts but i won't use Your script. Your script is mere third party workaround. Nothing more. Not a fix for a problem. I am not going to add, modify or delete any entries using tdp scripts, not in case where desktop app has an explicit function to logout user - function which doesn't do what it should.
I realize your post is old, but this was the first result that popped up when I searched this issue so I thought I would share my solution here for anyone else who comes looking.

In Windows 10, open Settings -> Accounts -> Access work or school

Click on the account you want Teams to forget, then click Disconnect.

I tried deleting/disconnecting my school account but teams on my computer still won't let me logout. Any ideas? Thanks @Erin_Rose5 

this is how to disconnect, but the real issue is how to stop windows from adding the Teams login account into "email and accounts" in the first place.

Hey!! Thanks alot for this! The script code worked and the problem was solved!!!

I'm having this issue too.. For a public facing application, this is abysmal... Logging out of an app is basic functionality.
I'm having this same issue and cannot get logged out of Teams. Ay solutions to the super messed up problem?

Hi @awarwick


It is unbelievable we are even having this conversation.   This is such a basic issue and one that would be so easy to test and fix if you were Microsoft - they have the source code.   


I have noticed there are several different sign out boxes in teams (some on the same page) and in testing this problem they appear to work differently.    It is unacceptable from a quality point of view (not to mention a CX perspective) for two identical menu options to operate in a different way.   And if that wasn't the intention, then why have the two on the one screen?


I experience this problem (cannot log out of teams) on a MAC.  I have two emails accounts I use for different teams families.    This problem presents itself in a few different ways.


Sometime I even get a screen that invites me to enter one email address and password and then TEAMS logs me into my OTHER email's account.   Microsoft seem to have an issue with identity where people writing the code make the incorrect assumption the whole world works with ONE email account.   I had the same issue with federated identity in Queensland Health a few years ago - visiting medical officers ended up with two email accounts (their private one and the hospital's one).  


I don't want workarounds for this.   I want the problem fixed.   It's just basic functionality that should just work.


Peter Grant




Were either of you able to find a solution?

@Peter_Grantit's exactly what I said earlier. We can use workarounds, ok, but it is ridicule considering who brands Teams. I can use workarounds for small free apps written by nobody. And not able to log out is not the only problem i have met. The problem where application closes itself right after start without any explicit error is also haunting it. The best way to deal with both problems is just remove all Teams data placed in users folder.