I am trying to replace the value of a variable in parameters file using Replace(). This file which I am trying to edit accepts json format. But I am unable to do so. I am using this below script to do so. This only print the name of that particular field for which I am trying to replace a numeric value.
I tried this but it just displays the name of the variable which contains the old value I am trying to edit/replace.
if($Value -like "*xyz*")
{
$Value -replace '$OldValue', '$NewValue'
}
else
{
Write-Host "$OldValue"
}
Please provide a solution so that I can replace a numeric value of a particular variable for json file.
CodePudding user response:
Good day Tanya
You should be able to use this:
if ($value -like *xyz*) {
$value.replace($oldValue,$newValue)
} else {
Write-Host $oldValue
Have a nice day
CodePudding user response:
$value ='tata'
Set-Variable -Name value -Value 'changed'