Powershell & cmdlet - In a Nutshell - Part 5 - Listing Service Information using Windows Powershell & cmdlet

How to list Service Information using Windows Powershell & cmdlet:  

In Exchange Server 2007, Get-Service cmdlet will be used to retrieve information about the services installed on the computer. By default, it will return the results in alphabetical order.

(1) Get information about the services installed 

Get-Service

It will list/get you the information about the service name, status and, display name.

(2) Get information about the services in sorted

Get-Service | Sort-Object status, displayname

Here,
Sort-Object - the cmdlet can sort the data in any way we want, Status - service property which needs to be filtered, display - represents display name

(3) Get information about the services installed, but only for running services

Get-Service | Where-Object {$_.status –eq "running"}

Here, Where-Object - the cmdlet filters out everything except those services that are stopped, $ _.  - the object passed across the pipeline, Status - service property which needs to be filtered, -eq "running" - represents the running services

(4) Get information about the services installed, but only for stopped services

Get-Service | Where-Object {$_.status –eq "stopped"}

Here, Where-Object - the cmdlet filters out everything except those services that are stopped, $_.  - the object passed across the pipeline, Status - service property which needs to be filtered, -eq " stopped" - represents the stopped services