I want to run a powershell command only if a certain string does not exist in a certain file.
This is my script
$pattern='<!--add key="MaxNumCycles" value="40"/-->'
$textToAdd=$pattern + '
<!--RerunMode: 1 write to DB, 2 write to DB and add to RUN export/-->
<add key="RerunMode" value="0"/>'
$filename="C\temp\Software.exe.config"
[IO.File]::ReadAllText($filename).Replace($pattern,$textToAdd) | Set-Content $filename -Force
If the $textToAdd string is not in $filename then I want to run this script. How do I go about this?