Check for process owner on remote machine and kill it when owner is xyz

ぐ巨炮叔叔 提交于 2020-01-14 19:51:09

问题


Hey I want to check on an remote computer for a process owner of a specific process and kill it when the owner is for example xyz. I already managed it to check for the owner but I don't know how to kill it when the owner is xyz.

What I have so far:

get-wmiobject -computername remotePC win32_process|where{$_.name -eq "firefox.exe"}|select name,@{n="owner";e={$_.getowner().user}}

回答1:


Get-WmiObject -Class Win32_Process -Filter "Name='firefox.exe'" -ComputerName remotePC | 
Where-Object { $_.GetOwner().User -eq 'xyz' } | 
Foreach-Object { $_.Terminate() }


来源:https://stackoverflow.com/questions/11670466/check-for-process-owner-on-remote-machine-and-kill-it-when-owner-is-xyz

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