The Format of Teams Setting File desktop-config.json

Brass Contributor

Hello,

 

I have a question on Teams setting file desktop-config.json

In the company, after installing Teams we must do some preset settings, for example, prevent Teams from auto-starting with system. I think there's an easy way:

$settings = Get-Content "$env:APPDATA\Microsoft\Teams\desktop-config.json" | ConvertFrom-Json
$disable_autostart = "{`"openAtLogin`": false}" | ConvertFrom-Json
$settings | Add-Member -MemberType NoteProperty -Name "appPreferenceSettings" -Value $disable_autostart
$settings | ConvertTo-Json | Set-Content "$env:APPDATA\Microsoft\Teams\desktop-config.json"
But the new desktop-config.json doesn't work, I have to deal with it as a string, like this:
$Teams_config_file = "$env:APPDATA\Microsoft\Teams\desktop-config.json"
$disable_auto_start = ",`"appPreferenceSettings`":{`"openAtLogin`":false}}"
(Get-Content $Teams_config_file -Raw) -replace "}$",$disable_auto_start | Set-Content -LiteralPath $Teams_config_file
Is there a way to modify the configurations as real json codes rather than plain strings?
Thank you. 
 
Regards,
C. L
 

 

2 Replies

@chenrylee 

Hi,

 

maybe a bit late but check the how the coding of the .json file output is.

 

The .json written back to file system most probably contains BOM (Byte Order Marks) which the original file doesn't!

You can check this if you look at the file in HEX. If your file starts with EF BB BF byte order marks are set for your file.

Teams is ignoring this file and will overwrite it with its default.

 

One way to provide is using a .NET function as there is no BOM set:

$jsonObject = ConvertTo-Json -InputObject $psConfigObject -Depth 4 -Compress
[System.IO.File]::WriteAllLines($configFilepath, $jsonObject )

 

Hope this helps!

 

Best regards,

JF