Filter the output of a command as if it was text

I have a simple question, but I am also a beginner in PowerShell. I think it has to do with the fact that the output of the Get-Process command (alias ps) is objects and not text.

I want to get a list of the services running that have the name "sql" in them.

This is what I tried so far, but every attempt returns nothing:

Get-Service | where {$_ -match 'sql'}

Get-Service | where {$_ -like 'sql'}

Get-Service | Select-String sql

I am looking for a pattern that lets me treat the output of every command as searchable text.


The other answers are right of course about your specific question of starting services that have "sql" in their name, but to answer the generic question:

You can do Get-Service | Out-String, and you will get the output as string, much like how Unix commands work.

Also when the output is piped to non-PowerShell commands, it does get converted to text, so for example: Get-Service | grep sql would work the way you wanted.

But again, like @JPBlanc says, it is good embrace the way PowerShell works, which is that the outputs are objects. It gives you way more control and keeps things simple and readable (the Unix commands with sed, awk and what not operating on text output of other command outputs can get very cryptic!).