Get-Service -Name *sql*
A longer alternative would be:
Get-Service | where-object {$_.name -like '*sql*'}
Many cmdlets offer built-in filtering and wildcard support. If you check the help files (Get-Help Get-Service -full), you will see
-name <string[]> Specifies the service names of services to be retrieved. Wildcards are permitted. By default, Get-Service gets all of the services on the comp uter. Required? false Position? 1 Default value * Accept pipeline input? true (ByValue, ByPropertyName) Accept wildcard characters? true
Typically, if filtering is built into the cmdlet, this is the preferred transition method because it is often faster and more efficient.
In this case, there may not be many performance benefits, but in V2, where you could pull services from a remote computer and filter, there would be a preferred method (less data to send back to the calling computer).
source share