PowerShell: using grep alike command

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 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 your love