Skip to content

Starting and Stopping Processes

PowerShell provides a clean, object‑oriented way to start, stop, inspect, and manage processes on Windows, macOS, and Linux. Unlike traditional shells that return plain text, PowerShell returns rich process objects, allowing you to filter, sort, and pipe them into other commands.

This section covers the essential cmdlets:

  • Start-Process
  • Get-Process
  • Stop-Process

1. Starting Processes

The primary cmdlet for launching applications is Start-Process.

It can start GUI apps, console apps, scripts, installers, and more.


1.1 Starting a simple application

Start-Process "notepad.exe"

This opens Notepad in a new window.


1.2 Starting a process with arguments

Start-Process "notepad.exe" -ArgumentList "C:\Data\notes.txt"

This opens Notepad and loads the file.


1.3 Starting a process in a specific directory

Start-Process "powershell.exe" -WorkingDirectory "C:\Scripts"

1.4 Starting a process and waiting for it to finish

Start-Process "msiexec.exe" -ArgumentList "/i app.msi" -Wait

Useful for installers or long‑running tasks.


1.5 Starting a process and capturing the exit code

$p = Start-Process "ping.exe" -ArgumentList "localhost" -Wait -PassThru
$p.ExitCode
  • PassThru returns a process object so you can inspect it.

2. Getting Process Information

Use Get-Process to list running processes.


2.1 Listing all processes

Get-Process

Returns objects with properties like:

  • Name
  • Id
  • CPU
  • WorkingSet
  • StartTime

2.2 Filtering by name

Get-Process -Name "notepad"

2.3 Filtering by ID

Get-Process -Id 1234

2.4 Sorting processes

Get-Process | Sort-Object CPU -Descending

2.5 Selecting specific properties

Get-Process | Select-Object Name, Id, CPU

3. Stopping Processes

Use Stop-Process to terminate processes.


3.1 Stopping by name

Stop-Process -Name "notepad"

This stops all Notepad instances.


3.2 Stopping by process ID

Stop-Process -Id 1234

3.3 Forcing termination

Stop-Process -Name "chrome" -Force

Use -Force carefully—this kills the process immediately without cleanup.


4. Combining Cmdlets for Real‑World Tasks


4.1 Restarting a process

$proc = Get-Process -Name "notepad" -ErrorAction SilentlyContinue

if ($proc) {
    Stop-Process -Id $proc.Id
}

Start-Process "notepad.exe"

4.2 Killing all processes using too much memory

Get-Process |
    Where-Object { $_.WorkingSet -gt 500MB } |
    Stop-Process -Force

4.3 Monitoring a process until it exits

$p = Start-Process "notepad.exe" -PassThru
$p.WaitForExit()
"Notepad closed."

5. Summary

Task Cmdlet
Start a process Start-Process
List running processes Get-Process
Stop a process Stop-Process
Wait for a process to finish Start-Process -Wait
Get exit code Start-Process -PassThru

PowerShell’s process management commands are powerful, consistent, and ideal for automation, monitoring, and system administration.