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