How to use grep-like commands in PowerShell

PowerShell

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 the filename and 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}