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:

Deploy to your devices and enjoy your Microsoft Teams application on Windows having its settings automatically configured.

ENJOY 🙂

4 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

Leave a Comment

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