Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell - Using regular expressions to find and replace lines in test file

$
0
0

Currently im trying to create a script that will open a file and if any lines begin with the text i supply, it will delete the entire line. I keep getting convoluted information on escape characters and how they should be applied

My script is as follows:

Powershell
try{cd$env:APPDATA\Mozilla\Firefox\Profiles\*.default-ErrorActionStopGet-Content.\prefs.js|Where{$_-notmatch'user_pref`(`"network`.automatic`-ntlm`-auth`.trusted`-uris`"'}|Set-Contentfilteredfile.txt}catch{$ErrorMessage=$_.Exception.Message$FailedItem=$_.Exception.ItemName}finally{Echo$ErrorMessageEcho$FailedItem}

What im trying to do is delete any line that begins with:

user_pref("network.automatic-ntlm-auth.trusted-uris"


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>