Syntax error How to stop the specific instance of the process in PowerShell?

How to stop the specific instance of the process in PowerShell?



To stop the specific instance of the process, Process ID needs to provide to Stop-Process cmdlet.

Example

In the below example, we need to stop Notepad process with instance ID 25400.

Output

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    228      14     3156      13680       0.13   4900   1 notepad
    232      14     3196      13752       0.16  25400   1 notepad
Stop-Process -Id 25400

Now, when Get-Process command is run, there will be no process running with –Id 25400.

Command

PS C:\WINDOWS\system32> Get-Process -Name notepad

Output

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    227      13     2808      13492       0.14   4900   1 notepad

Updated on: 2020-01-22T12:28:44+05:30

345 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements