Introduction
OK, so the story here is, that many organizations – including ourselves – has taken on the use of Microsoft Teams.
This means that management and configuration of application settings, becomes highly relevant and interesting. Microsoft Teams in its current state of the application for Windows, comes with 5 settings which potentially needs to be configured:
- Auto-start application
- Open application in background
- On close, keep the application running
- Disable GPU hardware acceleration
- Register Teams as the chat app for Office
For this purpose I have created a Powershell script, which can be run with Configuration Manager (explained in this post) as well as Microsoft Intune (and probably other management systems as well).
Microsoft Teams
First off, here are some relevant details on where and how Microsoft Teams stores its settings.
There are no Administrative Templates / Group Policy options to manage Microsoft Teams (other than an irrelevant option to prevent Microsoft Teams from launching automatically with Windows).
So when digging into the application and looking for clues, I found that settings was saved into a .json file in the user’s profile: AppData\Roaming\Microsoft\Teams\desktop-config.json.
The actual .json file opened in Notepad++ illustrated below, where I have highlighted the 5 different settings.
In order for us to properly configure these settings, we need to be able to modify the content if this .json file. This is where Powershell comes to the rescue.
NOTE: In order to configure ‘Register Teams as the chat app for Office‘, simply modifying the .json file is not sufficient.
Monitoring Teams.exe with Process Monitor revealed that a new registry value in HKCU\SOFTWARE\IM Providers also is being set, thus this is something the Powershell script also takes care of.
Powershell
The Powershell script can be found on my GitHub page: https://github.com/imabdk/Powershell/blob/master/Config-TeamsAppSettings.ps1
Apologies for the lack of commenting throughout the script. Instead I have spent some time on proper logging for when run manually.
The script accepts 5 parameters, one for each setting, which I hope is self-explanatory:
- -openAsHidden $true/$false
- -openAtLogin $true/$false
- -runningOnClose $true/$false
- -disableGpu $true/$false
- -registerAsIMProvider $true/$false
The script does following in headlines:
- Looks for installation of Microsoft Teams
- Script will break if Microsoft Teams is not installed.
- Look for the Teams config file (.json)
- Get content of current config file (.json) and convert from JSON
- Stop Teams process from running
- This is needed to properly apply changes to the config file (.json)
- Apply new settings values to the JSON object
- Convert back to JSON
- Apply new content to the config file (.json)
- Launch Microsoft Teams again
- This is needed in order to properly reformat the config file (.json)
Configuration Manager
To run this with Configuration Manager, simply create a regular package similar to below illustrations:
Create a program, running a simple batch script, which again runs the Powershell script.
NOTE: I needed to run the Powershell script via a batch script in order to get Configuration Manager to accept the command line containing ‘$’-signs. Not sure why, but if I ran Powershell directly in the command line including ‘$’-signs, the program failed.
The batch script will contain following content. Modify the parameters where needed to suit your environment:
@ECHO OFF PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -Command "& '%~dpn0.ps1' -openAsHidden $true -openAtLogin $true -runningOnClose $true -disableGpu $false -registerAsIMProvider $false"
Deploy to your devices and enjoy your Microsoft Teams application on Windows having its settings automatically configured.
ENJOY 🙂
Can you configure language settings using this script?
I tried to edit manually the language part in desktop-config.json, but the Teams interface does not change.
I haven’t looked into changing the UI language I’m afraid, so cannot give any advice here.
Great post! BUT… Why use a package and not a Configuration Item to manage these settings? Would seem like an obvious choice, and would make the entire solution so much more powerful!
Ah, I knew that question would pop up, and I did consider making this a CI instead, but I like the reporting that comes with using a package 🙂
Also splitting the script into two would make it more difficult for one to use with Intune or other management solution IMO 🙂
Hi Martin this is a great post this script is working fine when i have tried manually but it does not work when i used through SCCM. I have deployed this with run with user’s right but still no luck please can you help me we have to make changes on 30000 machines.
Are you running the script as I describe in the post using a package? What does execmgr.log say?
i have the same problem.
Can you help me with what im doing wrong
Execmgr.log:
};
]LOG]!>
Thank you! surprised there was not a GPO for this. My one question is the criteria that the script needs to be run when a user is logged on. Is it possible to apply this during a Task Sequence? I am removing skype first and then installing teams. This is done for the few machines that are still 32 bit.
Thing is that Teams is installed for the logged on user and the application settings is done for each user profile. Also, I’m not sure, but I don’t think the settings file exists before the Teams application actually have run for the first time.
how about removing or making it “floatable” the “give control” bar when screen sharing?
Thanks for this!
Here is a post for German users:
https://www.itnator.net/ms-teams-start-einstellungen-desktop-config-json/
Lisa
After running the script it appears the changes to the JSON file were made, however Teams just sits at the loading screen forever and doesn’t actually open Teams. Not sure what the issue is. If I restore the original file back, it works fine again but changes were reversed.
Hmm, I must admit I haven’t tested this with very recent versions of Teams. What config options did you choose to change?
I just tested the script again with version 1.3.00.32283 x64 of Teams, and I don’t see that behavior. Can you shed some light on version and what options you are configuring to what setting?
Version 1.3.00.33674 x64
Looking to keep auto start on but I want to have it start in the background which I set to $true. I can confirm the json file does change but when teams tries to launch it just sits at the Launching Teams logo and never advances..
I think what I’m going to do is compare the new file to the backup copy and look for the differences and go from there..
Did you find a solution to your problem here? As I mentioned, I couldn’t reproduce what you’re describing 🙂
Did you find any solution for this? I’m getting the same problem as you now.
I think I found the reason for this. Microsoft introduced a Cookie file, which needs to be deleted in order for Teams to pick up the changes to the .json. C:\Users\Username\AppData\Roaming\Microsoft\Teams\Cookies
I will make some changes to the script to cater for this. Thank you! 🙂
I think I found the reason for this. Microsoft introduced a Cookie file, which needs to be deleted in order for Teams to pick up the changes to the .json. C:\Users\Username\AppData\Roaming\Microsoft\Teams\Cookies
I will make some changes to the script to cater for this. Thank you! 🙂
The saved json file is corrupt.
Search and Replace will work better and it is easy to understand 🙂
https://steebit.de/2022/microsoft-teams-starteinstellungen
Search on my blog for the same scenario, just done with Intune. There’s an updated script, which formats the .json differently and is not making it corrupt. Something changed in Teams during the period.
@Martin as always thanks for taking the time to develop this and share you code with community. New Year resolution is to be as smart as you in 2021….
We are not having much luck getting -registerAsIMProvider $true to successfully work. Even after the script runs and MS Teams is closed and relaunched it does not register it as the Default IM provider.
Anyone else had success? We will keep trying but welcome any input.
Hm, as far as I recall this requires changes to the registry as well, which my script also does. But how does this part come out in your end? What is registered with your registry here: HKCU:\SOFTWARE\IM Providers
Default IM app is set to Teams in HKCU but within Ms Teams / Settings “ Register Teams as the chat app for Office”, is not.
The HKCU reg key is indeed set to DefaultIMAp: Teams.
However within MS Teams settings the Register Teams as the chat app for Office is not selected.
Am I overlooking something?
Please note that the HKCU:\IM Providers is indeed set to DefaultIMApp: Teams but when Teams closes and relaunch with the script, it does not honor the setting.
Within MS Teams “Register Teams as the chat app for Office” is still not selected. Not sure where the disconnect is on my end if this works for others.
yeah, that’s weird. We did a major Teams rollup, and I changed that setting with my script too 🙂
Hej Martin,
Kan man köra scriptet, men utan att tvinga omstart på Teams tjänsten? Så inställningarna skrivs till .json filen, men appliceras nästa gång användaren startar om datorn själv typ? Vi vill tvinga ut detta till alla (GPU acc), men vill inte att vi tvingar en omstart av Teams tjänsten när kanske användare sitter mitt i ett Teams möte.
Then you just have to remove that bit of code within the script, or just comment it out with a ‘#’. 🙂
I tried to do that, but then it just didn´t apply the settings. When I removed the comment the script worked again. Anyway, I added this as an logon script with gpo, and that works for now.
Thanks!
Hm yeah, that’s because somehow Teams reformats the .json file, and a restarting Teams does that. It’s not really optimal to configure an app this way, but there are currently no other alternatives 🙁
When I run the script it works, but the Teams client just gets stuck on the load screen. Any help?
I have an updated script on my github which caters for this.
Yeah, I have an updated script on my github which solves this. The one used withe Endpoint Analytics. 🙂
This is a section in my json file that has this in it:
“profile”:{“aud”:”https://api.spaces.skype.com”,”iss”:”https://sts.windows.net/867a2f9d-fc7b-4d84-8106-02709d5a8b62/”,… (and much more)
And when I run the script to change the settings, this is converted to a full on string that starts with:
“profile”:”@{aud=https://api.spaces.skype.com; iss=https://sts.windows.net/867a2f9d-fc7b-4d84-8106-02709d5a8b62/; iat=
And it hoses the loading of teams so it won’t run.
I don’t know what the solution is here but it’s messed up.
Hey Thomas, I know. At some point something changed in Teams, where the way the .json is being formatted by this script, is no longer “supported” in a sense. Instead, take a look at my latest post on the topic: https://www.imab.dk/configure-microsoft-teams-application-settings-using-proactive-remediations-in-microsoft-endpoint-manager-and-powershell/
In that example, I do use Intune instead, but the Configure-TeamsAppSettings.ps1 script has been modified, to no longer hose the config and therefore mess up the loading of teams. It wouldn’t require much to simply take the changes here, and implement in the “old” script you are using with ConfigMgr 🙂
Hey Martin,
Exactly what changes would need to be made to the old script in order to get it to work with ConfigMgr? I’m just trying to make sure I get this right and don’t pull over anything that’s specific to the Intune method. Is it just the command that deletes the Cookie file, or is more than that? Thanks so much!
amateurs
Hi, thanks for this step-by-step tutorial, very informative ! (although I’m not sure how to access the “Create Package wizard”).
Do you know how to set up parameters for teams such as read receipts and call encryption ?
A the moment, these 2 parameters are unchecked and need to be checked manually, which is a pain in the but to enforce in all the company (we have 50 licences).
Thanks 🙂
Do you have a script to set the opening of links in Teams (Settings -> Files and links)? I noticed the following is written to C:\Users\%username%\AppData\Local\Packages\MSTeams_8wekyb3d8bbwe\LocalCache\Microsoft\MSTeams:
“open_file_in_desktop_app”: true,
“open_file_in_desktop_app”: false,
I’m wanting to open Office files in the desktop app.
Is this also possible with the new Teams client? Trying to figure it out but no success yet.