Do you need to kill processes by name using PowerShell? Whether a program freezes, consumes too much CPU, or you need to automate cleanup tasks, PowerShell provides a powerful and flexible way to manage processes — far beyond what Task Manager offers.
In this tutorial, you’ll learn how to kill a process by name in PowerShell, using the built-in Stop-Process cmdlet. We’ll cover multiple methods, examples, and advanced use cases, including filtering, automation, and error handling.
What is a Process in Windows?
A process is an instance of a running program. Each process has:
- A Name (e.g.,
notepad,chrome,explorer) - A Process ID (PID) – a unique numeric identifier
- A Path – where the executable is located
- CPU and memory usage statistics
PowerShell can interact with all these attributes using cmdlets like:
Get-Process– to list running processesStop-Process– to terminate processes
Before you start:
- You must have Windows PowerShell 5.1 or PowerShell 7+ installed.
- Run PowerShell as Administrator when stopping system-level or protected processes.
Check out PowerShell Start-Process
Method 1: Kill Process by Name Using Stop-Process
The simplest way to kill a process by name is by using the Stop-Process cmdlet in PowerShell. This is the most straightforward approach and works across all Windows versions with PowerShell installed.
Syntax
Below is the syntax:
Stop-Process -Name "processName"Example
Below is an example.
Stop-Process -Name "notepad"This command stops all instances of Notepad currently running on the system. The process termination happens immediately, and all unsaved data will be lost unless the application has auto-save functionality.
-Namespecifies the process name (without.exe).- PowerShell automatically finds all processes matching that name and terminates them.
Here is the screenshot for your reference:

💡 Tip: You can confirm the process name using:
Get-Process | Select-Object Name, Id
Check out How to Use PowerShell Get-Process?
Method 2: Force Kill a Process
Sometimes a process refuses to terminate gracefully, especially when it’s hanging or frozen. Use the -Force parameter to ensure it’s stopped without any confirmation prompts or grace periods.
Example
Here is an example:
Stop-Process -Name "chrome" -ForceThis command forcefully terminates all Chrome processes running on your machine. The -Force parameter bypasses any shutdown handlers that the application might have, making it similar to using “End Task” in Task Manager.
⚠️ Warning: The
-Forceparameter can cause data loss if the process is writing to disk. Use it only when necessary.
Read How to Pass Variables to a PowerShell Script?
Method 3: Kill Multiple Processes by Name
You can target multiple processes simultaneously by separating names with commas. This is particularly useful for closing related applications or performing bulk cleanup operations.
Example:
Below is an example:
Stop-Process -Name "notepad", "calc", "mspaint"This stops Notepad, Calculator, and Paint in one command. If any of the specified processes aren’t running, PowerShell will display an error for those specific processes but continue with the others.
Method 4: Kill Process by Name Using Get-Process and Pipeline
For more control, combine Get-Process with Stop-Process using the pipeline (|). This method gives you the ability to inspect processes before terminating them and provides better error handling.
Example:
Below is an example:
Get-Process -Name "notepad" | Stop-ProcessThis approach is useful when you want to filter, log, or analyze processes before killing them. You can also add additional pipeline commands to count processes or check their memory usage before termination.
Check out Check if a Module Is Installed using PowerShell
Method 5: Kill Process by Partial Name (Using Wildcards)
You can use wildcards (*) to match partial names. This is especially helpful when dealing with processes that have version numbers or dynamic names.
Example:
Below is an example:
Get-Process -Name "*note*" | Stop-ProcessThis kills any process whose name contains “note” (e.g., notepad, onenote). Be careful with wildcards as they might match more processes than intended, so always test with Get-Process first.
Method 6: Kill Process by Path or Condition (Where-Object)
If multiple processes share the same name but are launched from different locations, you can filter by path. This method is crucial when you have multiple versions of the same application installed in different directories.
Example:
Below is an example:
Get-Process -Name "appname" | Where-Object { $_.Path -like "*C:\Program Files\AppFolder*" } | Stop-ProcessThis ensures only the process from a specific folder is terminated. You can also filter by other properties like CPU usage, memory consumption, or start time to target specific instances.
Read How to Check Hard Drive Space using PowerShell?
Method 7: Kill Process Remotely
If you have admin rights, you can stop a process on a remote computer. This capability is essential for managing server farms or multiple workstations from a central location.
Example:
Below is an example:
Invoke-Command -ComputerName "Server01" -ScriptBlock { Stop-Process -Name "notepad" -Force }This command connects to Server01 and kills all Notepad processes remotely. You’ll need appropriate network permissions and the remote computer must have PowerShell remoting enabled via Enable-PSRemoting.
Method 8: Error Handling and Logging
Always handle errors gracefully, especially in automation scripts. Proper error handling prevents scripts from crashing and provides valuable diagnostic information when processes can’t be terminated.
Example:
Here is an example:
try {
Stop-Process -Name "wordpad" -ErrorAction Stop
Write-Output "Process stopped successfully."
} catch {
Write-Warning "Failed to stop process: $_"
}This script attempts to stop WordPad and logs an error if it fails. You can enhance this by adding timestamps, writing to event logs, or sending email notifications for critical process management failures.
Check out How to Get .NET Version Using PowerShell?
Troubleshooting Tips
Here are some troubleshooting tips you should follow.
| Issue | Possible Cause | Solution |
|---|---|---|
| “Access Denied” | Insufficient permissions | Run PowerShell as Administrator |
| Process restarts automatically | Background service or watchdog | Disable the service first |
| Process not found | Wrong name | Use Get-Process to confirm the exact name |
Best Practices
- Test with
Get-Processfirst before killing anything. - Avoid using
-Forceunless absolutely necessary. - Log activity in production scripts.
- Use filters to target only the specific process you intend to stop.
- Run as Administrator when managing system-level processes.
PowerShell Kill Process by Name Examples
Let’s say you want to close all Chrome processes every night to save memory. Then you can use the below PowerShell script:
Script Example:
Below is the complete script:
$processName = "chrome"
if (Get-Process -Name $processName -ErrorAction SilentlyContinue) {
Stop-Process -Name $processName -Force
Write-Output "All Chrome processes stopped successfully."
} else {
Write-Output "No Chrome processes found."
}Save this as Kill-Chrome.ps1 and schedule it with Task Scheduler for nightly cleanup.
Conclusion
In this tutorial, I explained how to use PowerShell to kill processes by it name. Whether you’re managing local or remote systems, PowerShell’s Stop-Process cmdlet is very useful for any system administrator.
You may also like:
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.