Home > Mobile >  Why isnt powershell replacing my string here?
Why isnt powershell replacing my string here?

Time:02-03

I'm basing my script off of enter image description here

If you want to replace the entire line that contains a word then use this:

$preferenceFile = 'C:\Users\Clint.Oliveira\Desktop\preferences.xml'
$hold = @()
foreach($line in Get-Content $preferenceFile) {
    if($line -match 'CacheFolder'){
        $hold = $line -replace $line, 'NONSENSE '
        $Out  = $hold
    }
    else{$Out  = $line}
}
$Out | Set-Content $preferenceFile  -Force

enter image description here

  •  Tags:  
  • Related