Consider JSON in this format :
{
"Statement": " Check this content ",
"Version": "3.2.0",
"Parameters": [
{
"Name": "Parameter1",
"Value": "10"
},
{
"Name": "Parameter2",
"Value": "5"
}
]
}
In Powershell3, I need to check the Version value, if its "3.2.0", I want to change the Value of "Parameter2" to 32. I was thinking this way:
# Convert the json file to powershell object
$a = Get-Content -Raw $configfile.ToString() | ConvertFrom-Json
# Apply condition
if($a.version -eq '3.2.0'){
$a.parameters | % {if($_.name -eq 'parameter2'){$_.value=32}}}
Please guide on how can I achieve this.
Aucun commentaire:
Enregistrer un commentaire