Skip to content

Querying and Controlling Windows Services

Windows services are long‑running background processes that start automatically, manually, or on demand. PowerShell provides a full set of cmdlets to query, start, stop, restart, and configure services. These cmdlets return service objects, allowing you to filter, sort, and pipe them just like any other PowerShell data.

The core cmdlets are:

  • Get-Service
  • Start-Service
  • Stop-Service
  • Restart-Service
  • Set-Service

1. Querying Services

1.1 Listing all services

Get-Service

This returns objects with properties such as:

  • Name
  • DisplayName
  • Status
  • ServiceType
  • CanStop

1.2 Filtering by name

Get-Service -Name "wuauserv"

This retrieves the Windows Update service.

You can use wildcards:

Get-Service -Name "win*"

1.3 Filtering by status

Get-Service | Where-Object { $_.Status -eq "Running" }

Or:

Get-Service | Where-Object Status -eq Running

1.4 Sorting services

Get-Service | Sort-Object Status, Name

2. Starting and Stopping Services

2.1 Starting a service

Start-Service -Name "wuauserv"

If the service is already running, nothing happens.


2.2 Stopping a service

Stop-Service -Name "wuauserv"

If the service cannot be stopped (e.g., system‑critical), PowerShell throws an error.


2.3 Restarting a service

Restart-Service -Name "wuauserv"

This is equivalent to stopping and then starting the service.


2.4 Forcing a stop

Some services require -Force:

Stop-Service -Name "Spooler" -Force

Use this carefully—forcing a stop may interrupt system functionality.


3. Inspecting Service Objects

Because Get-Service returns objects, you can inspect their properties:

$svc = Get-Service -Name "Spooler"

$svc.Status
$svc.CanStop
$svc.ServiceType

You can also pipe service objects into other cmdlets:

Get-Service Spooler | Stop-Service

4. Changing Service Startup Type

Use Set-Service to configure how a service starts.

4.1 Setting a service to automatic

Set-Service -Name "Spooler" -StartupType Automatic

4.2 Setting a service to manual

Set-Service -Name "Spooler" -StartupType Manual

4.3 Disabling a service

Set-Service -Name "Spooler" -StartupType Disabled

5. Real‑World Examples

5.1 Restarting the Print Spooler

Restart-Service -Name "Spooler"

Useful for fixing stuck print jobs.


5.2 Checking which services failed to start

Get-Service | Where-Object { $_.Status -eq "Stopped" -and $_.StartType -eq "Automatic" }

This identifies services that should be running but aren’t.


5.3 Starting all stopped services that can be started

Get-Service |
    Where-Object { $_.Status -eq "Stopped" -and $_.CanStart } |
    Start-Service

5.4 Monitoring service status in real time

Get-Service -Name "wuauserv" | Format-Table Status, Name -AutoSize -Repeat

(Requires PowerShell 7+)


6. Summary

Task Cmdlet
List services Get-Service
Start a service Start-Service
Stop a service Stop-Service
Restart a service Restart-Service
Change startup type Set-Service

PowerShell’s service‑management cmdlets give you full control over Windows services, making it easy to automate maintenance, troubleshoot issues, and build reliable administration scripts.