I have a script where I am basically doing a find and replace on several strings of text. The first couple of strings work, but when I do the account keys, they do not. How can I fix this problem?
Here is the script:
Get-ChildItem "[FILEPATH]" -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$c = $c -replace 'abt7d9epp4','w2svuzf54f'
$c = $c -replace 'AccountName=adtestnego','AccountName=zadtestnego'
$c = $c -replace 'AccountKey=eKkij32jGEIYIEqAR5RjkKgf4OTiMO6SAyF68HsR/Zd/KXoKvSdjlUiiWyVV2+OUFOrVsd7jrzhldJPmfBBpQA==','DdOegAhDmLdsou6Ms6nPtP37bdw6EcXucuT47lf9kfClA6PjGTe3CfN+WVBJNWzqcQpWtZf10tgFhKrnN48lXA=='
[IO.File]::WriteAllText($_.FullName, ($c -join "`r`n"))
}
'-replace' does a regex search and you have special characters in that last one (like +) So you might use the non-regex replace version like this:
$c = $c.replace('AccountKey=eKkij32jGEIYIEqAR5RjkKgf4OTiMO6SAyF68HsR/Zd/KXoKvSdjlUiiWyVV2+OUFOrVsd7jrzhldJPmfBBpQA==','DdOegAhDmLdsou6Ms6nPtP37bdw6EcXucuT47lf9kfClA6PjGTe3CfN+WVBJNWzqcQpWtZf10tgFhKrnN48lXA==')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With