Doctor Scripto: "Configuring Startup Settings in Microsoft Teams with Windows PowerShell" faild : JSON-primitieve

Bender, Thomas 1 Reputation point
2022-11-03T11:16:41.08+00:00

dear all,

when i run this script form Doctor Scripto:

# Get Teams Configuration  
$FileContent=Get-Content -Path "$ENV:APPDATA\Microsoft\Teams\desktop-config.json"  
# Convert file content from JSON format to PowerShell object  
$JSONObject=ConvertFrom-Json -InputObject $FileContent          # <--- error  
# Update Object settings  
$JSONObject.appPreferenceSettings.OpenAsHidden=$true  
$JSONObject.appPreferenceSettings.OpenAtLogin=$true  
$JSONObject.appPreferenceSettings.RunningOnClose=$False  
Get-Process Teams | Stop-Process -Force  
# Convert Object back to JSON format  
$NewFileContent=$JSONObject | ConvertTo-Json  
# Update configuration in file  
$NewFileContent | Set-Content -Path "$ENV:APPDATA\Microsoft\Teams\desktop-config.json"  

I keep on getting the fooling error and i cannot figure out what is going wrong:

ConvertFrom-Json : Ongeldige JSON-primitieve: C.  
At line:4 char:13  
+ $JSONObject=ConvertFrom-Json -InputObject $FileContent  
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException  
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand  

the variable $FileContent contains the content of $ENV:APPDATA\Microsoft\Teams\desktop-config.json

can someone help me out?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,081 Reputation points
    2022-11-08T09:17:52.297+00:00

    Hi. Thank you for your question and reaching out.

    I am so sorry about that. To Setup Microsoft Teams' Startup Options Using Windows PowerShell, please see https://devblogs.microsoft.com/scripting/configuring_startup_settings_in_microsoft_teams_with_windows_powershell/
    I believe it will be easier for you to check this out on your end.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments