Select-String is probably not the hammer you wanna use for this particular nail (see below) :-)

Get-Process has a -Name parameter that takes a wildcard:

Get-Process -Name nginx
# or
Get-Process -Name *nginx*

To kill the process, either call Kill() directly on the object:

$nginxProcess = Get-Process nginx |Select -First 1
$nginxProcess.Kill()

... or simply pipe the process instances to Stop-Process:

Get-Process -Name nginx |Stop-Process

As you can see, we never actually need to locate or pass the process id - the Process object already has that information embedded in it, and the *-Process cmdlets are designed to work in concert - PowerShell is all about command composition, and this is an example of it.

That being said, Stop-Process is also perfectly capable of killing processes by name alone:

Stop-Process -Name nginx

How did I know the *-Process cmdlets had a -Name parameter?

Apart from reading the help files and documentation (I get it, I don't want to read anything either unless I absolutely have to ;-)), a quick way to learn about the parameters exposed by a cmdlet is by running Get-Command <commandName> -Syntax:

PS ~> Get-Command Stop-Process -Syntax

Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

The output shows us 3 distinct "parameter sets" (combinations of parameter input accepted by the command), and the required and optional arguments we can pass to it.


What's wrong with Select-String?

The Select-String cmdlet is the PowerShell cognate to grep - it takes some input, and performs regular expression matching against it based on whatever pattern you give it.

But grep is only useful when you're operating on strings - and as you've already found, Get-Process returns structured .NET objects, not flat strings.

Instead, the PowerShell-idiomatic approach is to filter the data, using the Where-Object cmdlet:

Get-Process | Where-Object Name -like '*nginx*'

Here, we instruct Where-Object to only let through object that have a Name property, the value of which must satisfy the wildcard pattern *nginx*.

Where-Object also supports arbitrary filter expressions, by accepting a scriptblock - PowerShell will assign the current pipeline object being evaluated to $_ (and $PSItem):

Get-Process | Where-Object { $_.Name -like '*nginx*' }

... which you can extend to whatever degree you need:

# Only let them through if a specific user is executing
Get-Process | Where-Object { $_.Name -like '*nginx*' -and $env:USERNAME -ne 'Quarkly'}
Answer from Mathias R. Jessen on Stack Overflow
Top answer
1 of 2
8

Select-String is probably not the hammer you wanna use for this particular nail (see below) :-)

Get-Process has a -Name parameter that takes a wildcard:

Get-Process -Name nginx
# or
Get-Process -Name *nginx*

To kill the process, either call Kill() directly on the object:

$nginxProcess = Get-Process nginx |Select -First 1
$nginxProcess.Kill()

... or simply pipe the process instances to Stop-Process:

Get-Process -Name nginx |Stop-Process

As you can see, we never actually need to locate or pass the process id - the Process object already has that information embedded in it, and the *-Process cmdlets are designed to work in concert - PowerShell is all about command composition, and this is an example of it.

That being said, Stop-Process is also perfectly capable of killing processes by name alone:

Stop-Process -Name nginx

How did I know the *-Process cmdlets had a -Name parameter?

Apart from reading the help files and documentation (I get it, I don't want to read anything either unless I absolutely have to ;-)), a quick way to learn about the parameters exposed by a cmdlet is by running Get-Command <commandName> -Syntax:

PS ~> Get-Command Stop-Process -Syntax

Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

The output shows us 3 distinct "parameter sets" (combinations of parameter input accepted by the command), and the required and optional arguments we can pass to it.


What's wrong with Select-String?

The Select-String cmdlet is the PowerShell cognate to grep - it takes some input, and performs regular expression matching against it based on whatever pattern you give it.

But grep is only useful when you're operating on strings - and as you've already found, Get-Process returns structured .NET objects, not flat strings.

Instead, the PowerShell-idiomatic approach is to filter the data, using the Where-Object cmdlet:

Get-Process | Where-Object Name -like '*nginx*'

Here, we instruct Where-Object to only let through object that have a Name property, the value of which must satisfy the wildcard pattern *nginx*.

Where-Object also supports arbitrary filter expressions, by accepting a scriptblock - PowerShell will assign the current pipeline object being evaluated to $_ (and $PSItem):

Get-Process | Where-Object { $_.Name -like '*nginx*' }

... which you can extend to whatever degree you need:

# Only let them through if a specific user is executing
Get-Process | Where-Object { $_.Name -like '*nginx*' -and $env:USERNAME -ne 'Quarkly'}
2 of 2
1

Note: PowerShell must be run as Administrator in order to execute these commands.

Kill a process with a known PID:

Syntax:

Stop-Process -Force -Id <pid>

Example:

Stop-Process -Force -Id 1234

Kill a process with a known name:

Syntax:

Stop-Process -Force -Name <name>

Example:

Stop-Process -Force -Name Taskmgr

Kill a process with a name wildcard search pattern

Syntax:

Get-Process -Name <pattern> | Stop-Process -Force

Example:

Get-Process -Name *skmg* | Stop-Process -Force
🌐
Sacha's Blog
sachabarbs.wordpress.com › 2014 › 10 › 22 › powershell-killing-all-processes-of-name
Powershell : Killing all processes of name | Sacha's Blog
October 22, 2014 - Now I am just starting with PowerShell, so I will likely come up with some ridiculously simple examples. One of thing I really like about PowerShell is the ability to pipe things from one CmdLet to another. Imagine you want to get all instances of the the running process “notepad” and kill them.
People also ask

How do I stop a PowerShell command from running?

You can interrupt and stop a PowerShell command while it is running by pressing Control-C. A script can be stopped with the command exit. This will also close the PowerShell console.

🌐
comparitech.com
comparitech.com › home › net admin › tutorial: powershell kill process command
PowerShell Kill Process Command: Step-by-Step Tutorial
How do I kill Windows processes from the command line?

At the command line, you can terminate a Windows process with the command taskkill. To use this command, you need to know its process ID (PID). You can get a list of all running tasks with the command tasklist. Once you know the PID, use the taskkill command in this manner: taskkill /PID /F. Type in the process ID without quotes instead of .

🌐
comparitech.com
comparitech.com › home › net admin › tutorial: powershell kill process command
PowerShell Kill Process Command: Step-by-Step Tutorial
What is the kill PID command?

The kill command is used on Linux to terminate a running process. The format is just kill followed by the process ID. You can get a list of running processes by using the top command. The kill command doesn’t work in Windows – use taskkill instead.

🌐
comparitech.com
comparitech.com › home › net admin › tutorial: powershell kill process command
PowerShell Kill Process Command: Step-by-Step Tutorial
🌐
Reddit
reddit.com › r/powershell › stopping multiple processes, some with the same name
r/PowerShell on Reddit: Stopping Multiple Processes, Some with the same name
August 23, 2017 -

Let me start off with, for as advanced as I am in my career with windows, PowerShell is my Achilles heal. I am trying to remedy that.

I have a server that is running Solarwinds. Until we can get it rebuilt there is a problem happening where Solarwinds is chewing up all the Windows Sockets. The remedy has been to kill all of the Solarwinds Processes and then restart the software.

So I have been tasked with writing a script that we can run as a scheduled task. While I understand the Stop-Process cmdlt, how can I use it to kill multiple processes at once, some with the same name (ex. SolarWinds.BuisnessLayerHost.exe*32 shows up like 20 times as a running process)?

🌐
Comparitech
comparitech.com › home › net admin › tutorial: powershell kill process command
PowerShell Kill Process Command: Step-by-Step Tutorial
November 11, 2024 - To stop a process by its ID, use taskkill /F /PID <PID>, such as taskkill /F /ID 3127 if 3127 is the PID of the process that you want to kill. To stop a process by its name, use taskkill /IM <process-name> /F, for example taskkill /IM mspaint.exe /F.
Find elsewhere
🌐
PDQ
pdq.com › blog › what-is-the-powershell-equivalent-of-taskkill
What is the PowerShell equivalent of taskkill? | PDQ
February 12, 2026 - TL;DR: The PowerShell equivalent of taskkill is Stop-Process. It terminates running processes by name or ID, supports force-stopping unresponsive apps, and works natively with Get-Process for safer scripting.
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.management › stop-process
Stop-Process (Microsoft.PowerShell.Management) - PowerShell | Microsoft Learn
The Stop-Process cmdlet stops one or more running processes. You can specify a process by process name or process ID (PID), or pass a process object to Stop-Process. Stop-Process works only on processes running on the local computer.
🌐
Dzhavat Ushev
dzhavat.github.io › 2020 › 04 › 09 › powershell-script-to-kill-a-process-on-windows.html
PowerShell script to kill a process on Windows | Dzhavat Ushev
The only thing left now is to kill the process using the PID number. ... Phew, that was a lot! I really enjoyed taking this experiment. Before starting it, I felt intimidated by the thought of writing a PowerShell script. I thought it was really complicated. Now I’m glad I tried it.
🌐
Marc Nuri
blog.marcnuri.com › home › windows: how to kill a process from the command line
Windows: How to kill a process from the command line - Marc Nuri
October 31, 2023 - Taskkill also supports killing a process by its name. To do so, you can use the following command: ... To kill a process from PowerShell, we will use the Stop-Process cmdlet.
🌐
Virtualization Howto
virtualizationhowto.com › home › devops › powershell kill a process from the command line
PowerShell Kill a Process from the Command Line - Virtualization Howto
August 16, 2024 - With Windows Management Instrumentation capabilities, Windows PowerShell allows users to manage processes on their local computers and remote systems. # Kill all instances of Notepad on a remote computer named 'RemotePC1' Invoke-Command -ComputerName RemotePC1 -ScriptBlock { Stop-Process -Name notepad -Force }
🌐
PowerShell Forums
forums.powershell.org › powershell help
Kill process of a different user remotely - PowerShell Help - PowerShell Forums
August 25, 2016 - Hi there, I’m just learning the ... need to kill a specific task that is run on a remote computer by all users that are not currently logged in. I want to be able to run the command on a Windows 7 machine. What I got so far: Get-WmiObject win32_process -computername AAA | select name,@{n=“ow...
🌐
Java2Blog
java2blog.com › home › powershell › powershell kill process by name
PowerShell Kill Process by Name [4 Ways] - Java2Blog
June 20, 2023 - In this method, only write the name of the process without extension. For example, do not write "notepad.exe" instead, write "notepad". Use the Terminate() method to kill the process by name in PowerShell.
🌐
Quora
quora.com › How-do-I-kill-all-processes-with-the-same-name-in-Windows
How to kill all processes with the same name in Windows - Quora
Use the exact process name (without path) for -Name or /IM; for PowerShell Get-Process the Name excludes the .exe extension. /F (Force) forcibly terminates; prefer without /F or without -Force if graceful shutdown is acceptable.
🌐
Windows 10 Forums
tenforums.com › tutorials › 101472-kill-process-windows-10-a.html
Kill a Process in Windows 10 - Windows 10 Help Forums
January 1, 2018 - A) Type the command below into PowerShell, and press Enter. (see screenshot below) Stop-Process -Name " ... ProcessName in the command above with the actual ProcessName (ex: "OneDrive") from step 2 above for the process you want to kill.
🌐
NinjaOne
ninjaone.com › home › blog › it ops › how to kill a process in windows: 4 methods
How to Kill a Process in Windows | NinjaOne
April 30, 2025 - If you know the name of the process, you can terminate it with the PowerShell Stop-Process by typing Stop-Process -Name “ProcessName” -Force.
🌐
ITPRC
itprc.com › home › network tools
How To Use PowerShell To Kill Processes - Step-by-Step Guide
March 12, 2021 - If you’re following along in PowerShell, you can type taskkill /? to bring up additional information. /f Tells the command to run forcefully, and is recommended when running taskkill. /pid Specifies the process ID. After this syntax would be the process ID that needs to be killed. /im Represents the image name that you wish to terminate.
🌐
ITT Systems
ittsystems.com › home › powershell kill process command – step-by-step tutorial
PowerShell Kill Process CommandL Step-by-Step Tutorial
July 26, 2023 - Best practices for using PowerShell Kill Process include identifying the correct process ID or name, verifying that the process should be terminated, and testing the cmdlet in a non-production environment. Organizations can use PowerShell Kill Process in conjunction with other PowerShell cmdlets and scripting tools to automate process management tasks. Limitations of PowerShell Kill Process can include the inability to terminate processes that are protected by security features or access controls, and the potential for unintended consequences if used improperly.