0

I have an appsettings.json file that looks like this

{
"ApiSettings": {
    "EnableSwagger": true,
    "UrlListeners": [
        "http://localhost:9000"
    ],
    "DebugMode":  true
},
}

And I am wanting to write some powershell that changes the "UrlListeners" portion. So far I've got

$DebugValue = 'false'
$JsonFile = Get-Content .\appsettings.json -raw | ConvertFrom-Json
$JsonFile.ApiSettings.DebugMode = $DebugValue
$JsonFile | ConvertTo-Json -Depth 9| Set-Content .\appsettings.json

However instead of just outputting "DebugMode": false I get "DebugMode": "false"

How do I set the value with it having quotes? Thanks in advance

2
  • 2
    $DebugValue = $false. In other words, you need a regular Boolean value here, not a string Commented Oct 4, 2022 at 13:50
  • Isn't it easy when you know how! Thanks for the help, seems so obvious now!! Commented Oct 4, 2022 at 13:52

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.