How to use operator '-replace' in PowerShell to replace strings of texts with special characters and replace successfully

后端 未结 3 2206
既然无缘
既然无缘 2020-12-18 17:59

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

3条回答
  •  Happy的楠姐
    2020-12-18 18:38

    In your example, you prepended your source string with AccountKey= but not your target string.

    $c = $c -replace 'AccountKey=eKkij32jGEIYIEqAR5RjkKgf4OTiMO6SAyF68HsR/Zd/KXoKvSdjlUiiWyVV2+OUFOrVsd7jrzhldJPmfBBpQA==','AccountKey=DdOegAhDmLdsou6Ms6nPtP37bdw6EcXucuT47lf9kfClA6PjGTe3CfN+WVBJNWzqcQpWtZf10tgFhKrnN48lXA=='
    

    By not including that in the target string, the resulting string will remove AccountKey= instead of replacing it. You correctly do this with the AccountName= example, which seems to support this conclusion since it is not giving you any problems. If you really mean to have that prepended, then this may resolve your issue.

提交回复
热议问题