24/7/365 Support

Stop a Windows PowerShell Process

Problem

You want to stop (or kill) a process on the system.

Solution

To stop a process, use the StopProcess cmdlet, as shown in Example 212.

Example 212. Stopping a process using the StopProcess cmdlet

PS >notepad PS >GetProcess Notepad

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName

42 3 1276 3916 32 0.09 3520 notepad

PS >StopProcess ProcessName notepad PS >GetProcess Notepad

Example 212. Stopping a process using the StopProcess cmdlet (continued)

GetProcess : Cannot find a process with the name 'Notepad'. Verify the process name and call the cmdlet again. At line:1 char:12

+ GetProcess <<<< Notepad

Discussion

While the parameters of the StopProcess cmdlet are useful in their own right, PowerShell’s pipeline model lets you be even more precise. The StopProcess cmdlet stops any processes that you pipeline into it, so an advanced process set generated by GetProcess automatically turns into an advanced process set for the StopProcess cmdlet to operate on:

PS >GetProcess | WhereObject { $_.WorkingSet lt 10mb } | >> SortObject Descending Name | StopProcess WhatIf >> What if: Performing operation "StopProcess" on Target "svchost (1368)". What if: Performing operation "StopProcess" on Target "sqlwriter (1772)". What if: Performing operation "StopProcess" on Target "qttask (3672)". What if: Performing operation "StopProcess" on Target "Ditto (2892)". What if: Performing operation "StopProcess" on Target "ctfmon (3904)". What if: Performing operation "StopProcess" on Target "csrss (848)". What if: Performing operation "StopProcess" on Target "BrmfRsmg (1560)". What if: Performing operation "StopProcess" on Target "AutoHotkey (3460)". What if: Performing operation "StopProcess" on Target "alg (1084)".

Notice that this example uses the –WhatIf flag on the StopProcess cmdlet. This flag lets you see what would happen if you were to run the command but doesn’t actually perform the action.

For more information about the StopProcess cmdlet, type GetHelp StopProcess. For more information about the WhereObject cmdlet, type GetHelp WhereObject.

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 128 GB (SSD SATA) Configure Server
Intel Atom C2750 2.4 GHz 8c/8t 8 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Xeon E3-1230 v2 3.3 GHz 4c/8t 16 GB DDR3 1× 256 GB (SSD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 250 GB (SSD SATA) Configure Server

What Our Clients Say