bschelst/ April 5, 2017/ PowerShell/ 0 comments

In Powershell, you can also use a grep like you can do on Linux.
In order to search for a string in a file, you can use the following command:

   sls "Searchthisstring" "C:\myfile.log" -ca

If you want to have the output without filename, line number:

sls “Searchthisstring” “C:\myfile.log” -ca | Foreach-Object {$_.Line}

If you want to ‘grep’ multiple words, you can use the ‘pattern’ argument:

sls -pattern “Searchthisstring|thesecondword” “C:\myfile.log” -ca | Foreach-Object {$_.Line}

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

5 × five =