The essentials
Quick reference
One focused task per row. Jump to the related section for complete, working examples.
| Use | Syntax | Examples |
|---|---|---|
| List processes | Get-Process | View examples |
| Find processes by name | Get-Process -Name 'pwsh' | View examples |
| Find a process by ID | Get-Process -Id 4242 | View examples |
| Rank memory use | Get-Process |
Sort-Object -Property WorkingSet64 -Descending |
Select-Object -First 10 Name, Id, WorkingSet64 | View examples |
| Start a process | $process = Start-Process -FilePath 'notepad.exe' `
-PassThru | View examples |
| Pass process arguments | Start-Process -FilePath 'notepad.exe' -ArgumentList `
'C:\Temp\notes.txt' | View examples |
| Wait for a process | Wait-Process -Id $process.Id -Timeout 30 | View examples |
| Preview process stopping | Stop-Process -Id 4242 -WhatIf | View examples |
| Confirm process stopping | Stop-Process -Id 4242 -Confirm | View examples |
| List Windows services | Get-Service | View examples |
| Find a service by name | Get-Service -Name 'Spooler' | View examples |
| List running services | Get-Service |
Where-Object -Property Status -EQ 'Running' | View examples |
| Show required services | Get-Service -Name 'WinRM' -RequiredServices | View examples |
| Show dependent services | Get-Service -Name 'WinRM' -DependentServices | View examples |
| Preview starting a service | Start-Service -Name 'Spooler' -WhatIf | View examples |
| Preview stopping a service | Stop-Service -Name 'Spooler' -WhatIf | View examples |
| Preview restarting a service | Restart-Service -Name 'Spooler' -WhatIf | View examples |
| Set automatic startup | Set-Service -Name 'BITS' -StartupType Automatic -WhatIf | View examples |
| Inspect startup settings | Get-Service -Name 'BITS' |
Select-Object Name, Status, StartType | View 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
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.
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.
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.
$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.
Start-Process -FilePath 'notepad.exe' -ArgumentList 'C:\Temp\notes.txt' 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.
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.
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.
Get-Service
Get-Service -Name 'Spooler'
Get-Service | Where-Object -Property Status -EQ 'Running' 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.
Get-Service -Name 'WinRM' -RequiredServices
Get-Service -Name 'WinRM' -DependentServices 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.
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.
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.
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.
Sources and further reading
References
Authoritative documentation used to verify and expand this cheat sheet.
Help us improve
Found a typo or missing example?
Tell us what would make this cheat sheet clearer, more complete, or more useful.



