I have a text file that contains a like that is similar to
Settings amount ="01:00:00"
I know how to replace the line but my issue is at the moment I am only able to replace the entire line if I know the exact contents of the line- using -match
and -replace
. However, is there a way that I can search for just Settings amount =
and then just replace that entire line with my new setting? That way no matter what the current value is I have the power to scan and give it a different value.
This is what I have currently.
$DesiredTime = 'Settings amount="06:00:00" />'
$path = "C:\Windows\File.txt"
(Get-Content $path) -replace 'Settings amount="01:00:00" />', $DesiredTime | out-file $path
Any ideas?