Kill processes run by specified user in powershell

眉间皱痕 提交于 2020-05-11 17:33:31

问题


Just wondering how can I kill all processes with the same name running by a specified user. For example, I could have multiple program.exe running by different users. I could use:

get-process program.exe | kill

to kill all of them. But I just want to kill those instances run by a specified user. Is there a convenient way to do that?


回答1:


TASKKILL.EXE /FI "USERNAME eq walid" /IM myprog.exe

You can also use wildcards:

TASKKILL.EXE /FI "USERNAME eq w*" /IM m*

For more details type: taskkill.exe /?




回答2:


This is for V5 (currently in preview) users, you can do this:

Get-Process program.exe -IncludeUserName | Where UserName -match joe | Stop-Process

The -IncludeUserName parameter requires that you are in an elevated console.



来源:https://stackoverflow.com/questions/26171165/kill-processes-run-by-specified-user-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!