- Courses
- đź’»Programming Languages
- 🪟PowerShell
- Scripting Fundamentals
- Working with Files, Processes & Services
- Starting and Stopping Processes
On this page
PowerShell Process Management – Starting, Inspecting, and Stopping Processes
Updated on June 17, 2026
By Enrico Hochkoeppler
Web Developer & TutoriaLibre Founder
PowerShell provides a complete set of cmdlets for working with processes on local and remote computers. Unlike traditional shells that return plain text output, PowerShell returns System.Diagnostics.Process objects — structured .NET objects with typed properties and callable methods. This means you can filter, sort, pipe, and act on process data using the full power of the PowerShell object pipeline.
The three primary process cmdlets are Get-Process, Start-Process, and Stop-Process. Supporting cmdlets Wait-Process and Debug-Process complement them for specific scenarios.
Getting Process Information with Get-Process​
Get-Process retrieves information about every running process on the local machine. Each result is a System.Diagnostics.Process object.
Listing all running processes​
Get-Process
This returns every running process. The default display shows Handles, NPM(K), PM(K), WS(K), CPU(s), Id, SI, and ProcessName. These columns are a formatted subset of the available properties — the underlying object has dozens more.
Filtering by process name​
Get-Process -Name "notepad"
-Name accepts wildcards and multiple comma-separated values. The .exe extension is never used in the process name:
# Wildcard — all processes whose names start with "power"
Get-Process -Name "power*"
# Multiple names in one call
Get-Process -Name "notepad", "explorer", "chrome"
-Name returns all matching instances. If three Notepad windows are open, all three process objects are returned.
Filtering by process ID​
Get-Process -Id 1234
Unlike -Name, specifying -Id with a non-existent ID raises an error rather than returning nothing, because the intent is always to find a specific known process. This is by design:
Get-Process -Id 99999
# Error: No process with process ID 99999 was found.
Use -ErrorAction SilentlyContinue when the process may or may not be running and you want to suppress the error:
$proc = Get-Process -Id 99999 -ErrorAction SilentlyContinue
if ($null -eq $proc) {
"Process not found"
}
Discovering all available properties​
The default table display shows only a subset of properties. To see everything available on a process object, pipe to Select-Object * or Get-Member:
# All properties and their current values
Get-Process -Name "explorer" | Select-Object *
# All properties, methods, and member types
Get-Process -Name "explorer" | Get-Member
Commonly useful properties beyond the defaults:
PropertyDescriptionIdProcess ID (PID)NameProcess name without .exe``CPUTotal CPU time in secondsWorkingSet64Physical memory usage in bytesVirtualMemorySize64Virtual memory size in bytesStartTimeWhen the process startedResponding``$true if the process is respondingMainWindowTitleTitle bar text (empty for background processes)PathFull path to the executableSessionIdThe Windows session the process runs inCompanyCompany name from the executable metadataDescriptionProcess description from the executable metadata
Sorting and selecting​
# Top 10 processes by CPU time descending
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, Id, CPU
# Top 5 by memory usage with readable MB column
Get-Process |
Sort-Object WorkingSet64 -Descending |
Select-Object -First 5 Name, Id,
@{ Name = "MemMB"; Expression = { [math]::Round($_.WorkingSet64 / 1MB, 1) } }
The calculated property @{ Name = "MemMB"; Expression = { } } creates a new column that converts the raw byte count to megabytes. WorkingSet64 returns bytes; dividing by 1MB and rounding produces a readable number.
Checking whether a specific process is running​
A common scripting requirement is to test whether a process is active before taking action:
$proc = Get-Process -Name "notepad" -ErrorAction SilentlyContinue
if ($proc) {
"Notepad is running with PID $($proc.Id)"
} else {
"Notepad is not running"
}
-ErrorAction SilentlyContinue suppresses the error when the process does not exist, returning $null instead. The if ($proc) check evaluates the object's truthiness — $null is falsy.
Getting processes on remote computers​
Get-Process -Name "powershell" -ComputerName "Server01", "Server02"
The MachineName property on the returned objects identifies which computer each process came from. Display it explicitly:
Get-Process -Name "powershell" -ComputerName "Server01", "Server02" |
Format-Table -Property Id, ProcessName, MachineName
Note: The
-ComputerNameparameter ofGet-Processuses DCOM and requires appropriate remote connectivity. For modern remoting, useInvoke-Commandwith a PSSession.
Finding non-responding processes​
The Responding property is $false for processes that have stopped responding to Windows messages (hung applications):
Get-Process | Where-Object { -not $_.Responding }
This pipeline returns every hung process. Pipe it to Stop-Process with -Force to terminate them all — with caution, as this kills them without cleanup.
Starting Processes with Start-Process​
Start-Process launches an executable, script, document, or URL. It replaces the older [System.Diagnostics.Process]::Start() call with a clean, parameter-driven interface.
Starting a simple application​
Start-Process "notepad.exe"
Notepad opens in a new window. The command returns immediately — by default, Start-Process does not wait for the launched process to finish.
Starting a process with arguments​
Start-Process "notepad.exe" -ArgumentList "C:\Data\notes.txt"
-ArgumentList passes one or more arguments to the executable. For multiple arguments, provide them as a single string or as an array:
# Single string with multiple arguments
Start-Process "ping.exe" -ArgumentList "-n 4 localhost"
# Array — each element is a separate argument
Start-Process "robocopy.exe" -ArgumentList @("C:\Source", "D:\Dest", "/MIR", "/LOG:C:\Logs\robocopy.log")
The array form is safer for paths containing spaces, because each element is passed as a distinct argument without requiring manual quoting.
Starting a process in a specific working directory​
Start-Process "powershell.exe" -WorkingDirectory "C:\Scripts"
-WorkingDirectory sets the current directory for the launched process. This matters for scripts or applications that reference relative paths.
Waiting for a process to finish​
Start-Process "msiexec.exe" -ArgumentList "/i C:\Installers\app.msi /quiet" -Wait
"Installation complete."
-Wait blocks the PowerShell session until the launched process exits. This is essential for sequencing — running commands after an installer finishes, waiting for a compilation step, or ensuring a file export is complete before processing its output.
Capturing the process object and exit code​
-PassThru returns a System.Diagnostics.Process object representing the started process. Without it, Start-Process returns nothing:
$p = Start-Process "ping.exe" -ArgumentList "localhost" -Wait -PassThru
"Exit code: $($p.ExitCode)"
-Wait and -PassThru are typically used together. -Wait ensures the process has finished before $p.ExitCode is read — reading ExitCode before the process exits returns $null.
Exit code 0 conventionally means success. Any non-zero value indicates a failure. The meaning of specific non-zero codes is defined by the application:
$p = Start-Process "msiexec.exe" -ArgumentList "/i app.msi /quiet" -Wait -PassThru
if ($p.ExitCode -eq 0) {
"Installation succeeded"
} elseif ($p.ExitCode -eq 3010) {
"Installation succeeded — reboot required"
} else {
"Installation failed with exit code $($p.ExitCode)"
}
Starting a process with elevated privileges​
Start-Process "powershell.exe" -Verb RunAs
-Verb RunAs triggers the UAC elevation prompt. The launched process runs as Administrator. This does not suppress the UAC prompt — the user must confirm it interactively.
Starting a process hidden​
Start-Process "ping.exe" -ArgumentList "-n 1 localhost" -WindowStyle Hidden -Wait -PassThru
-WindowStyle Hidden launches the process with no visible window. Useful for running background tools without cluttering the screen. Combine with -Wait -PassThru to inspect the exit code after the hidden process completes.
Starting a process with a different user​
$cred = Get-Credential
Start-Process "notepad.exe" -Credential $cred
-Credential runs the process under a different user account. Useful for testing application behaviour under a specific account's permissions.
Stopping Processes with Stop-Process​
Stop-Process terminates one or more running processes. It requires at minimum a name or ID.
Stopping by name​
Stop-Process -Name "notepad"
This stops all running instances of Notepad. If three Notepad windows are open, all three are terminated. There is no way to stop only one by name — use -Id to target a specific instance.
Stopping by ID​
Stop-Process -Id 1234
Targeting by ID is precise — it stops exactly one process. Retrieve the ID first with Get-Process if you need to stop a specific instance of a multi-instance application.
Forcing termination​
Stop-Process -Name "chrome" -Force
-Force sends a forcible termination signal. Without it, Stop-Process sends a close request (equivalent to clicking the X button), which the application may ignore or delay to clean up. With -Force, the process is terminated immediately without any cleanup opportunity.
Use -Force when a process is not responding or when you need immediate termination. Be aware that forced termination may leave files open, transactions uncommitted, or temporary files undeleted.
Confirming before stopping​
When using wildcards or stopping multiple processes, -Confirm adds a safety prompt before each termination:
Stop-Process -Name "t*" -Confirm
This prompts for confirmation before stopping each process whose name starts with t. Prevents accidental mass termination when the wildcard matches more processes than expected.
Checking the result after stopping​
-PassThru returns the process object after the stop operation, allowing you to verify the termination:
$stopped = Stop-Process -Name "notepad" -PassThru
"Stopped: $($stopped.Name) (PID $($stopped.Id))"
Waiting for Processes with Wait-Process​
Wait-Process blocks until one or more processes exit. It provides more control than Start-Process -Wait for processes that were started elsewhere:
# Wait for a specific process by name
Wait-Process -Name "notepad"
# Wait for a specific process by ID
Wait-Process -Id 1234
# Wait with a timeout — if the process does not exit within 30 seconds, continue
Wait-Process -Name "notepad" -Timeout 30
-Timeout specifies a maximum wait time in seconds. When the timeout expires without the process exiting, Wait-Process raises an error. Use this to avoid waiting indefinitely for a hung process:
try {
Wait-Process -Name "LongTask" -Timeout 60 -ErrorAction Stop
"Process completed within 60 seconds"
}
catch {
"Process did not complete within 60 seconds — killing it"
Stop-Process -Name "LongTask" -Force
}
Practical Process Management Patterns​
Safely restart a process​
$processName = "notepad"
$proc = Get-Process -Name $processName -ErrorAction SilentlyContinue
if ($proc) {
Stop-Process -Id $proc.Id -Force
Wait-Process -Id $proc.Id -ErrorAction SilentlyContinue
}
Start-Process "$processName.exe"
"$processName restarted."
Wait-Process after Stop-Process ensures the process has fully terminated before the restart. Without the wait, Start-Process might launch the new instance while the old one is still shutting down. -ErrorAction SilentlyContinue on Wait-Process handles the case where the process exits before Wait-Process begins.
Kill all processes exceeding a memory threshold​
$thresholdMB = 500
Get-Process |
Where-Object { $_.WorkingSet64 -gt ($thresholdMB * 1MB) } |
Select-Object Name, Id, @{ Name = "MemMB"; Expression = { [math]::Round($_.WorkingSet64 / 1MB, 1) } } |
ForEach-Object {
Write-Warning "Terminating $($_.Name) (PID $($_.Id)) using $($_.MemMB) MB"
Stop-Process -Id $_.Id -Force
}
Where-Object filters to processes above the memory threshold. ForEach-Object logs a warning and terminates each one. This pattern is useful in automated maintenance scripts running as scheduled tasks.
Stop all other PowerShell sessions​
$PID is an automatic variable containing the current process's ID. Exclude it to avoid stopping the session you are working in:
Get-Process -Name "powershell", "pwsh" |
Where-Object { $_.Id -ne $PID } |
Stop-Process -PassThru |
ForEach-Object { "Stopped PowerShell session PID $($_.Id)" }
This terminates every PowerShell process except the current one. -PassThru returns the stopped process objects so the ForEach-Object block can log each termination.
Monitor a process until it exits​
$p = Start-Process "notepad.exe" -PassThru
Write-Host "Monitoring Notepad (PID $($p.Id))..."
while (-not $p.HasExited) {
$p.Refresh() # refresh cached process data
$memMB = [math]::Round($p.WorkingSet64 / 1MB, 1)
Write-Host "Memory: $memMB MB" -NoNewline
Write-Host "`r" -NoNewline
Start-Sleep -Seconds 2
}
"Notepad exited with code $($p.ExitCode)"
$p.HasExited checks whether the process has terminated. $p.Refresh() updates the in-memory cached values from the operating system — without calling Refresh(), properties like WorkingSet64 and CPU return stale values. The loop runs every 2 seconds until the process exits.
Run a process on a remote computer​
Stop-Process has no -ComputerName parameter. For remote process management, use Invoke-Command:
# Start a process on a remote computer
Invoke-Command -ComputerName "Server01" -ScriptBlock {
Start-Process "notepad.exe" -Wait
}
# Stop a process on a remote computer
Invoke-Command -ComputerName "Server01" -ScriptBlock {
Stop-Process -Name "notepad" -Force
}
# Get processes from multiple remote computers via Invoke-Command
$servers = "Server01", "Server02", "Server03"
Invoke-Command -ComputerName $servers -ScriptBlock {
Get-Process | Where-Object { $_.WorkingSet64 -gt 200MB }
} | Sort-Object -Property PSComputerName, WorkingSet64 -Descending
Invoke-Command establishes a PSRemoting session and runs the script block on the target computer. The PSComputerName property on the returned objects identifies which server each result came from.
Process Management Cmdlet Reference​
CmdletPrimary parametersPurposeGet-Process``-Name, -Id, -ComputerNameRetrieve running process informationStart-Process``-FilePath, -ArgumentList, -WorkingDirectory, -Wait, -PassThru, -Verb, -WindowStyle, -CredentialLaunch a new processStop-Process``-Name, -Id, -Force, -Confirm, -PassThruTerminate a running processWait-Process``-Name, -Id, -TimeoutBlock until a process exitsDebug-Process``-Name, -IdAttach a debugger to a running process
Common Mistakes to Avoid​
Using -Name when you need to target one specific instance. -Name "notepad" stops all Notepad processes. When multiple instances are running, use -Id with the specific PID obtained from Get-Process.
Reading ExitCode before the process exits. ExitCode is $null until the process has terminated. Always use -Wait with Start-Process -PassThru, or call Wait-Process, before reading ExitCode.
Not calling $p.Refresh() in a monitoring loop. Process object properties are cached at retrieval time. Memory usage, CPU time, and status properties do not update automatically — call $p.Refresh() before reading them in a loop.
Using Stop-Process on remote computers without Invoke-Command. Stop-Process lacks a -ComputerName parameter. Wrap it in Invoke-Command for remote execution.
Forgetting -Force on non-responding processes. A hung process will not respond to a normal stop request. -Force is required to terminate it.
Using wildcards with Stop-Process without -Confirm or -WhatIf. Stop-Process -Name "c*" might match Chrome, Cortana, and other critical processes simultaneously. Test with Get-Process -Name "c*" first, or add -WhatIf to preview what would be stopped.
Found this helpful? Share the knowledge...
... or support this project to keep it alive!
Previous
Managing Files and Directories
Next
Querying and Controlling Windows Services
-
Getting Process Information with
Get-Process- Listing all running processes
- Filtering by process name
- Filtering by process ID
- Discovering all available properties
- Sorting and selecting
- Checking whether a specific process is running
- Getting processes on remote computers
- Finding non-responding processes
-
Starting Processes with
Start-Process- Starting a simple application
- Starting a process with arguments
- Starting a process in a specific working directory
- Waiting for a process to finish
- Capturing the process object and exit code
- Starting a process with elevated privileges
- Starting a process hidden
- Starting a process with a different user
-
Stopping Processes with
Stop-Process- Stopping by name
- Stopping by ID
- Forcing termination
- Confirming before stopping
- Checking the result after stopping
-
Waiting for Processes with
Wait-Process -
Practical Process Management Patterns
- Safely restart a process
- Kill all processes exceeding a memory threshold
- Stop all other PowerShell sessions
- Monitor a process until it exits
- Run a process on a remote computer
-
Process Management Cmdlet Reference
-
Common Mistakes to Avoid
