Managing Services & Processes
25 minHunt down stopped services, preview restarts safely with -WhatIf, and silence memory-hungry processes — the real on-call toolkit.
- ▸Filter services by Status and StartType using Get-Service and Where-Object
- ▸Preview and execute service restarts with -WhatIf, Start-Service, Stop-Service, and Restart-Service
- ▸Identify top memory consumers with Get-Process and Sort-Object
- ▸Terminate unresponsive processes safely using Stop-Process -Force -Id
- ▸Automate bulk restarts with ForEach-Object across a filtered service list
Services & Processes: The On-Call Toolkit
It is 02:00. Monitoring wakes you: the nightly ETL job has failed again. Nine times out of ten the culprit is a Windows service that stopped quietly. This module is how you fix it — fast, safely, and without guessing.
Getting a Picture of Your Services
Get-Service returns every service on the local machine:
Get-Service
Each object has three properties you will lean on constantly:
| Property | Example values |
|---|---|
Name | wuauserv, Spooler, bits |
Status | Running, Stopped, Paused |
StartType | Automatic, Manual, Disabled |
Narrow to services that should be running — StartType Automatic AND currently Stopped:
Get-Service | Where-Object { $_.StartType -eq 'Automatic' -and $_.Status -eq 'Stopped' }
These are your suspects.
Changing Service State Safely
Before you touch anything, use -WhatIf. Every *-Service cmdlet supports it:
Restart-Service -Name 'Spooler' -WhatIf
# What if: Performing the operation "Restart-Service" on target "Print Spooler (Spooler)".
No change occurs — you just confirm the right target. When you are happy:
Restart-Service -Name 'Spooler'
Start-Service -Name 'bits'
Stop-Service -Name 'Spooler'
Finding Heavy Processes
Get-Process lists every running process. The WS (Working Set) property is RAM in bytes. Sort descending and take the top five:
Get-Process | Sort-Object WS -Descending | Select-Object -First 5
To kill an unresponsive process use -Id (never rely on name alone — multiple processes can share a name) and add -Force for stubborn ones:
Stop-Process -Id 4812 -Force
Bulk Restarts with ForEach-Object
Automate the restart of every stopped-but-should-be-running service in one pipeline:
Get-Service |
Where-Object { $_.StartType -eq 'Automatic' -and $_.Status -eq 'Stopped' } |
ForEach-Object { Restart-Service -Name $_.Name -Verbose }
When You Need Richer Data
Get-Service is fast but lean. Get-CimInstance Win32_Service returns extra fields such as PathName, ProcessId, and Description:
Get-CimInstance -ClassName Win32_Service -Filter "State = 'Stopped' AND StartMode = 'Auto'"Quick check
Scenario: The Stopped ETL Service
You are on call for CorpInfra Ltd. At 02:14 a monitoring alert fires: the overnight ETL pipeline has failed for the third night running. You RDP to ETL-SRV-01 and open PowerShell as Administrator. Your goal: identify every service that should be running but isn't, check for a runaway process, and restore normal operation — without making a change you haven't previewed first.
Start by taking stock. Pipe Get-Service through Where-Object to show only services whose Status is 'Stopped'.