The essentials

Quick reference

One focused task per row. Jump to the related section for complete, working examples.

UseSyntaxExamples
List processesGet-ProcessView examples
Find processes by nameGet-Process -Name 'pwsh'View examples
Find a process by IDGet-Process -Id 4242View examples
Rank memory useGet-Process | Sort-Object -Property WorkingSet64 -Descending | Select-Object -First 10 Name, Id, WorkingSet64View examples
Start a process$process = Start-Process -FilePath 'notepad.exe' ` -PassThruView examples
Pass process argumentsStart-Process -FilePath 'notepad.exe' -ArgumentList ` 'C:\Temp\notes.txt'View examples
Wait for a processWait-Process -Id $process.Id -Timeout 30View examples
Preview process stoppingStop-Process -Id 4242 -WhatIfView examples
Confirm process stoppingStop-Process -Id 4242 -ConfirmView examples
List Windows servicesGet-ServiceView examples
Find a service by nameGet-Service -Name 'Spooler'View examples
List running servicesGet-Service | Where-Object -Property Status -EQ 'Running'View examples
Show required servicesGet-Service -Name 'WinRM' -RequiredServicesView examples
Show dependent servicesGet-Service -Name 'WinRM' -DependentServicesView examples
Preview starting a serviceStart-Service -Name 'Spooler' -WhatIfView examples
Preview stopping a serviceStop-Service -Name 'Spooler' -WhatIfView examples
Preview restarting a serviceRestart-Service -Name 'Spooler' -WhatIfView examples
Set automatic startupSet-Service -Name 'BITS' -StartupType Automatic -WhatIfView examples
Inspect startup settingsGet-Service -Name 'BITS' | Select-Object Name, Status, StartTypeView examples

PowerShell exposes processes and Windows services as structured objects. Inspect identity and state before acting, prefer a PID or exact service name over broad patterns, preview supported state changes with WhatIf, and elevate only when the selected target requires administrative rights.

Step by step

Detailed examples

01

Inspect process objects before acting

Get-Process returns System.Diagnostics.Process objects rather than formatted text. A process name can match several instances, while a PID identifies one current process but may be reused after exit. Select the fields needed for review and retain the object or revalidate its identity immediately before a state-changing command.

List, target, and rank processes
Get-Process
Get-Process -Name 'pwsh'
Get-Process -Id 4242
Get-Process |
    Sort-Object -Property WorkingSet64 -Descending |
    Select-Object -First 10 Name, Id, WorkingSet64

Note: The sample PID is illustrative and may not exist; obtain the intended process from current Get-Process output.

Back to quick reference ↑
02

Start a process and keep its identity

Start-Process launches a local program and returns no object unless PassThru is used. Retaining that object gives later commands a precise PID. ArgumentList passes arguments to the program, and paths containing spaces require careful quoting; use the target program's documented argument rules.

Open Notepad and wait briefly
$process = Start-Process -FilePath 'notepad.exe' -PassThru
Wait-Process -Id $process.Id -Timeout 30

Note: Wait-Process throws a non-terminating error if the timeout expires while the process is still running.

Open one text file
Start-Process -FilePath 'notepad.exe' -ArgumentList 'C:\Temp\notes.txt'
Back to quick reference ↑
03

Preview and confirm process termination

Stop-Process ends local processes and can target an ID, name, or process object. Preview the exact PID with WhatIf, then use Confirm when an interactive safeguard is appropriate. Stopping processes owned by another user can require elevation, and forcibly ending an application can discard unsaved work or interrupt dependent operations.

Inspect, preview, and confirm one PID
Get-Process -Id 4242 | Select-Object Name, Id, Path
Stop-Process -Id 4242 -WhatIf
Stop-Process -Id 4242 -Confirm

Note: Run the final command only after replacing the sample PID with a currently verified target.

Back to quick reference ↑
04

Inspect Windows service state

Get-Service returns ServiceController objects and is available only on Windows. Prefer the stable service Name for automation because DisplayName is intended for people and may be localized. Service state is a snapshot and can change between inspection and a later command.

List all, one, and running services
Get-Service
Get-Service -Name 'Spooler'
Get-Service | Where-Object -Property Status -EQ 'Running'
Back to quick reference ↑
05

Review service dependency relationships

RequiredServices shows what the selected service needs, while DependentServices shows what relies on it. Review both directions before stopping or reconfiguring a service because Windows may reject the operation or the change may disrupt dependent functionality.

Inspect WinRM dependencies
Get-Service -Name 'WinRM' -RequiredServices
Get-Service -Name 'WinRM' -DependentServices
Back to quick reference ↑
06

Preview service state changes

Start-Service, Stop-Service, and Restart-Service change the running state of a Windows service. Use WhatIf to preview the target and operation, check dependencies, and run the real command from an elevated session only when required. Restarting is not equivalent to reloading configuration for every service.

Preview Spooler state changes
Start-Service -Name 'Spooler' -WhatIf
Stop-Service -Name 'Spooler' -WhatIf
Restart-Service -Name 'Spooler' -WhatIf

Note: Remove WhatIf only after confirming the service name, dependencies, operational impact, and required permissions.

Back to quick reference ↑
07

Inspect and preview service startup configuration

Set-Service changes persistent properties such as StartupType and is Windows-only. Inspect the current value, preview the operation, and consider organizational policy before changing it. Setting a service to Automatic does not necessarily start it immediately, and disabling a service can break software that depends on it.

Review and preview BITS startup type
Get-Service -Name 'BITS' | Select-Object Name, Status, StartType
Set-Service -Name 'BITS' -StartupType Automatic -WhatIf
Get-Service -Name 'BITS' | Select-Object Name, Status, StartType

Note: The second inspection remains unchanged because WhatIf prevents the configuration update.

Back to quick reference ↑

Sources and further reading

References

Authoritative documentation used to verify and expand this cheat sheet.

  1. Microsoft LearnGet-Processlearn.microsoft.com
  2. Microsoft LearnStart-Processlearn.microsoft.com
  3. Microsoft LearnStop-Processlearn.microsoft.com
  4. Microsoft LearnGet-Servicelearn.microsoft.com
  5. Microsoft LearnSet-Servicelearn.microsoft.com

Help us improve

Found a typo or missing example?

Tell us what would make this cheat sheet clearer, more complete, or more useful.

Share feedback