But you are probably wondering how PowerShell is able to kill every instance of notepad with a single command.
The answer lies within the help of the Stop-Process cmdlet.
In this case, it accepts one or more process objects.
Technically, we would say that the InputObject cmdlet accepts a processarray.
Whenever you have a cmdlet that supports batch operations in this manner, use it.
This is choice number one.
Get-WmiObject -Class Win32_Process -Filter “name=‘notepad.exe’” | Invoke-WmiMethod -Name Terminate
Great, that did the trick.
Whenever you get a ReturnValue of 0 in WMI, just remember that the command executed successfully.
First you have to find the method you would use to stop a single process.