The Format of Teams Setting File desktop-config.json

%3CLINGO-SUB%20id%3D%22lingo-sub-749248%22%20slang%3D%22en-US%22%3EThe%20Format%20of%20Teams%20Setting%20File%20desktop-config.json%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-749248%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20question%20on%20Teams%20setting%20file%20%3CEM%3Edesktop-config.json%3C%2FEM%3E.%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20company%2C%20after%20installing%20Teams%20we%20must%20do%20some%20preset%20settings%2C%20for%20example%2C%20prevent%20Teams%20from%20auto-starting%20with%20system.%20I%20think%20there's%20an%20easy%20way%3A%3C%2FP%3E%3CDIV%3E%3CPRE%3E%3CSPAN%3E%24settings%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Content%3C%2FSPAN%3E%20%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24env%3AAPPDATA%3C%2FSPAN%3E%3CSPAN%3E%5CMicrosoft%5CTeams%5Cdesktop-config.json%22%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EConvertFrom-Json%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%24disable_autostart%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%22%7B%3C%2FSPAN%3E%3CSPAN%3E%60%22%3C%2FSPAN%3E%3CSPAN%3EopenAtLogin%3C%2FSPAN%3E%3CSPAN%3E%60%22%3C%2FSPAN%3E%3CSPAN%3E%3A%20false%7D%22%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EConvertFrom-Json%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%24settings%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EAdd-Member%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EMemberType%20NoteProperty%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EName%20%3C%2FSPAN%3E%3CSPAN%3E%22appPreferenceSettings%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EValue%20%3C%2FSPAN%3E%3CSPAN%3E%24disable_autostart%3C%2FSPAN%3E%3CBR%20%2F%3E%3CSPAN%3E%24settings%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EConvertTo-Json%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3ESet-Content%3C%2FSPAN%3E%20%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24env%3AAPPDATA%3C%2FSPAN%3E%3CSPAN%3E%5CMicrosoft%5CTeams%5Cdesktop-config.json%22%3C%2FSPAN%3E%3C%2FPRE%3E%3CDIV%3E%3CSPAN%3EBut%20the%20new%20%3CEM%3Edesktop-config.json%3C%2FEM%3Edoesn't%20work%2C%20I%20have%20to%20deal%20with%20it%20as%20a%20string%2C%20like%20this%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CPRE%3E%3CSPAN%3E%24Teams_config_file%20%3D%20%22%24env%3AAPPDATA%5CMicrosoft%5CTeams%5Cdesktop-config.json%22%3CBR%20%2F%3E%24disable_auto_start%20%3D%20%22%2C%60%22appPreferenceSettings%60%22%3A%7B%60%22openAtLogin%60%22%3Afalse%7D%7D%22%3CBR%20%2F%3E(Get-Content%20%24Teams_config_file%20-Raw)%20-replace%20%22%7D%24%22%2C%24disable_auto_start%20%7C%20Set-Content%20-LiteralPath%20%24Teams_config_file%3C%2FSPAN%3E%3C%2FPRE%3E%3CDIV%3EIs%20there%20a%20way%20to%20modify%20the%20configurations%20as%20real%20json%20codes%20rather%20than%20plain%20strings%3F%3C%2FDIV%3E%3CDIV%3EThank%20you.%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3ERegards%2C%3C%2FDIV%3E%3CDIV%3EC.%20L%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-749248%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETeams%20Settings%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-789602%22%20slang%3D%22en-US%22%3ERe%3A%20The%20Format%20of%20Teams%20Setting%20File%20desktop-config.json%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-789602%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F318077%22%20target%3D%22_blank%22%3E%40chenrylee%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Emaybe%20a%20bit%20late%20but%20check%20the%20how%20the%20coding%20of%20the%20.json%20file%20output%20is.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20.json%20written%20back%20to%20file%20system%20most%20probably%20contains%20BOM%20(Byte%20Order%20Marks)%20which%20the%20original%20file%20doesn't!%3C%2FP%3E%3CP%3EYou%20can%20check%20this%20if%20you%20look%20at%20the%20file%20in%20HEX.%20If%20your%20file%20starts%20with%20EF%20BB%20BF%20byte%20order%20marks%20are%20set%20for%20your%20file.%3C%2FP%3E%3CP%3ETeams%20is%20ignoring%20this%20file%20and%20will%20overwrite%20it%20with%20its%20default.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20way%20to%20provide%20is%20using%20a%20.NET%20function%20as%20there%20is%20no%20BOM%20set%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CEM%3E%3CFONT%20face%3D%22simsun%2Chei%22%3E%24jsonObject%20%3D%20ConvertTo-Json%20-InputObject%20%24psConfigObject%20-Depth%204%20-Compress%3C%2FFONT%3E%3C%2FEM%3E%3C%2FDIV%3E%3CDIV%3E%3CEM%3E%3CFONT%20face%3D%22simsun%2Chei%22%3E%5BSystem.IO.File%5D%3A%3AWriteAllLines(%24configFilepath%2C%20%24jsonObject%20)%3C%2FFONT%3E%3C%2FEM%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3EJF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1918194%22%20slang%3D%22en-US%22%3ERe%3A%20The%20Format%20of%20Teams%20Setting%20File%20desktop-config.json%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1918194%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F318077%22%20target%3D%22_blank%22%3E%40chenrylee%3C%2FA%3E%26nbsp%3BI%20suppose%20you%20found%20this%20one%20by%20now%3A%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Fscripting%2Fconfiguring_startup_settings_in_microsoft_teams_with_windows_powershell%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdevblogs.microsoft.com%2Fscripting%2Fconfiguring_startup_settings_in_microsoft_teams_with_windows_powershell%2F%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional 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
Highlighted

@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