Get-Service Service Management With Windows Powershell From Command Line – POFTUT

Get-Service Service Management With Windows Powershell From Command Line

Windows Powershell provides easy to use commands or command-lets to manage Windows systems. Powershell can be used to manage Windows Services and provides builtin command for related operations.


Help information about Powershell Services command can be get wit the following command.

$ Get-Help Get-Service
Get-Service Help
Get-Service Help

List Services with Get-Service

Existing Windows services can be listed with the Powershell command Get-Service . This will list all services currently running, stopped, suspended.

$ Get-Service
List Services with Get-Service
List Services with Get-Service

While listing services information about the service state, service name and service display name will be provided in separate columns.

Only List Running Services

In previous example we simply listed services but we may need to list only running services. In order to filter running services we will use Linux grep equivalent Where-Object like below.

$ Get-Service | Where-Object {$_.status -eq "running"}
Only List Running Services
Only List Running Services

Start Service

One of the most used practice of service command is starting the service. Syntax of starting service command is the same we just change the Verb part of the service command and use Start-Service by providing the service name. In this example we will start the service named RasAuto .

$  Start-Service RasAuto

Stop Service

Stopping a service is similar to starting we just change start to stop like below. In the example we will stop service named RasAuto

$  Stop-Service RasAuto

Restart Service

Restarting service is easy as starting and stopping service we will just use Restart-Service command with the service name. Restart will stop and start service if it is working. If it is not working service will just started.

$ Restart-Service RasAuto

Suspend Service

In Windows services can be suspended. It is similar to stopping the service but there are some differences. Suspended service will hold current situations and related data and variables. Also the service stop triggers will not run. In this example we will suspend service named MyService .

$ Suspend-Service MyService

In order to suspend a service the service should support suspension. If the service do not support suspension and we try to suspend the service we will get an error like below.

LEARN MORE  Nmap Host Discovery with Examples
Suspend Service
Suspend Service

Resume Service

Suspended service can be resumed with the Resume-Service command like below.

$ Resume-Service MyService

1 thought on “Get-Service Service Management With Windows Powershell From Command Line”

Leave a Comment