检查远程机器上的进程所有者并在所有者为 xyz 时将其杀死 [英] Check for process owner on remote machine and kill it when owner is xyz

查看:29
本文介绍了检查远程机器上的进程所有者并在所有者为 xyz 时将其杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想在远程计算机上检查特定进程的进程所有者,并在所有者是 xyz 时将其杀死.我已经设法检查它的所有者,但是当所有者是 xyz 时我不知道如何杀死它.

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}}

推荐答案

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

这篇关于检查远程机器上的进程所有者并在所有者为 xyz 时将其杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆