Process Information

Process Information – Powershell has feature allows one to list process information, list process by name. Also one can terminate process using “Stop-Process”

PS>Get-Process -Name <program name>

Example:
PS>Get-Process -Name gvim

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
95 7 3208 9496 65 0.16 172 gvim
108 7 3696 4900 65 0.95 1456 gvim

PS>Get-Process -Verbose

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
282 20 7944 13256 105 0.95 2824 AdobeARM
95 8 1468 4404 29 0.00 2652 alg
60 5 2164 5320 54 0.09 760 atchk

— store process in a variable
PS>$process = Get-Process gvim
— print the value in the variable
PS>$process

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
92 7 3128 9484 62 0.16 172 gvim
108 7 3696 4900 65 0.95 1456 gvim

— Show process with name gvim and using whatif option it let one view and the operation that will be applied on it
PS>Get-Process -Name gvim | Stop-Process -whatif
What if: Performing operation “Stop-Process” on Target “gvim (172)”.
What if: Performing operation “Stop-Process” on Target “gvim (1456)”.

— Show process with name gvim and using whatif option it let you confirm before the process is killed
PS>Get-Process -Name gvim | Stop-Process -confirm

Confirm
Are you sure you want to perform this action?
Performing operation “Stop-Process” on Target “gvim (172)”.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “Y”): N

Confirm
Are you sure you want to perform this action?
Performing operation “Stop-Process” on Target “gvim (1456)”.
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “Y”): Y

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.