Filter services when calling Get-Service

Get-Service -Name *sql*

A longer alternative would be:

Get-Service | where-object {$_.name -like '*sql*'}

Many cmdlets offer built in filtering and support wildcards. 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

Usually if filtering is built in to the cmdlet, that is the preferred way to go, since it is often faster and more efficient.
In this case, there might not be too much of a performance benefit, but in V2, where you could be pulling services from a remote computer and filtering there would be the preferred method (less data to send back to the calling computer).


You can get all the services that are running and having words sql.

 Get-Service | Where-Object {$_.Status -eq "Running"} | Where-Object {$_.Name -like "*sql*"}

If you want more information, see this (not much difference) http://nisanthkv.blog.com/2012/06/29/get-services-using-powershell

Hope it helps...


Please enter below command:

Get-Service -Name '*<search string>*'

Tags:

Powershell