Hello I am trying to modify a JSON file by using PowerShell. I want to pass a variable from PowerhShell that will replace two values(Placeholder1 and Placeholder2)in the JSON file. I have the following for the first value which is not working.
PowerShell
$a = Get-Content $pathToJson -raw | ConvertFrom-Json
$a.update | % {if($_.name -eq 'placeholder1'){$_.name=$record_name}}
$a | ConvertTo-Json -Depth 20 | set-content $pathToJson
JSON
{
"Comment": "Update record for Route 53",
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "placeholder1",
"Type": "CNAME",
"TTL": 300,
"ResourceRecords": [
{
"Value": "placeholder2"
}
]
}
}
]
}