I am having trouble finding how to find and replace in a file using poweshell. The file has several lines that are similar. I need to change the "ACT" to "RDY" in the line that starts with <PC_4 . All Lines start with < and end with >.
The Code:
powershell -Command(Get-Content C:\testfodler\test.XML) -replace '<PC_4 SET_THING="ACT">', '<PC_4 SET_THING="RDY">' | Out-File -encoding ASCII myFile.txt
The error I get is:
The '<' operator is reserved for future use.
Not all parse errors were reported. Correct the reported errors and try again.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported
Running this on a windows 10 machine.
PowerShell.exe -?and follow the-Commandsection: To write a string that runs a Windows PowerShell command, use the format:"& {<command>}"where the quotation marks indicate a string and the invoke operator (&) causes the command to be executed…powershell -Command "&{(Get-Content C:\testfodler\test.XML)}"