An essential thing to note is that PowerShell cmdlets always output objects, not simple strings - even when the output seems to be a string, it is really a System.String object. You can check the type of the output of a command (and the associated properties and methods) using Get-Member:
Get-Service | Get-Member
TypeName: System.ServiceProcess.ServiceController
Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName
RequiredServices AliasProperty RequiredServices = ServicesDependedOn
Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs)
Close Method void Close()
Continue Method void Continue()
...
As mentioned by others, Get-Service (and other cmdlets) has built-in filtering for what you're trying to do, but a more general alternative, which is more flexible (though often slower) is Where-Object:
Get-Service | Where-Object {$_.Name -like 's*' -and $_.Status -eq 'Running'}
Status Name DisplayName
------ ---- -----------
Running SamSs Security Accounts Manager
Running SCardSvr Smart Card
Running Schedule Task Scheduler
Running SecurityHealthS... Windows Security Service
Running SENS System Event Notification Service
...
get-service | select-object Status,Name | select-string nginx, I don't know how to prettify it, but I think you can try to add other or flatten the result.Select-StringwhenGet-Servicealready has many filtering options?