I am trying to override my contents within a json file but the contents keep adding to the line and not overriding. What did I do incorrectly?
$ActualContent = '"line1": "0 21 * * *'
$ContentToReplace = '"line1": "0 23 * * *'
Content = Get-Content $BaseFolder\$FileName -Raw
# Change Content
$Content -replace $ActualContent,$ContentToReplace | Set-Content $BaseFolder\$FileName
Write-Host " The content $ActualContent has been replaced with $ContentToReplace" -ForegroundColor Green
Before code : "line1": "0 21 * * *"
After code : line1": "0 23 * * ** * *"
I did notice that if I add the " to the end then the script doesnt work.