Configure Microsoft Teams application settings using Configuration Manager and Powershell

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 🙂

33 thoughts on “Configure Microsoft Teams application settings using Configuration Manager and Powershell”

  1. 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.

    Reply
  2. 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!

    Reply
    • 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 🙂

      Reply
  3. 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.

    Reply
  4. 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.

    Reply
    • 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.

      Reply
  5. 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.

    Reply
    • Hmm, I must admit I haven’t tested this with very recent versions of Teams. What config options did you choose to change?

      Reply
    • 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?

      Reply
      • 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..

        Reply
          • Did you find a solution to your problem here? As I mentioned, I couldn’t reproduce what you’re describing 🙂

          • 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! 🙂

          Reply
  6. @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.

    Reply
    • 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

      Reply
      • Default IM app is set to Teams in HKCU but within Ms Teams / Settings “ Register Teams as the chat app for Office”, is not.

        Reply
      • 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?

        Reply
      • 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.

        Reply
  7. 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.

    Reply
      • 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!

        Reply
        • 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 🙁

          Reply

Leave a Reply to Gerard Igoe Cancel reply

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