Using PowerShell, I want to replace all exact occurrences of [MYID] in a given file with MyValue. What is the easiest way to do so?
[MYID]
MyValue
Use (V3 version):
(Get-Content c:empest.txt).replace('[MYID]', 'MyValue') | Set-Content c:empest.txt
Or for V2:
(Get-Content c:empest.txt) -replace '[MYID]', 'MyValue' | Set-Content c:empest.txt
1.4m articles
1.4m replys
5 comments
57.0k users