Showing posts with label stop-process. Show all posts
Showing posts with label stop-process. Show all posts

Monday, January 19, 2009

stop a particular instance of the Notepad process by its ID

PS> stop-process -id 3952 -confirm -passthru

Explanation: ` -confirm ` parameter prompts the user before stopping the process. Because the prompt includes the process name, as well as its ID, this is best practice. ` -passthru ` parameter passes the process object to the formatter for display. (This is not applicable to graphical powershell)

stop all instances of the Notepad process

PS> stop-process -name Notepad

Explanation: (Each instance of Notepad runs in its own process.) It uses the Name parameter to specify the processes, all of which have the same name. If you were to use the ID parameter to stop the same processes, you would have to list the process IDs of each instance of Notepad.

terminate sessions of SQL

to terminate sessions of SQL Server with confirming

PS> get-process -name sql* | stop-process -passthru

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
52 2 900 3020 47 0.05 1564 sqlmangr

Warning!
Are you sure you want to perform this action?
Performing operation 'Stop-Process' on Target 'sqlservr(1072)'
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):l <--- stands for 'No to All'

prompt before proceed

to stop process with confirmation

PS> stop-process -Name * -confirm

Confirm
Are you sure you want to perform this action?
Performing operation "Stop-Process" on Target "csrss (472)".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):n <---- stands for 'No'