get-wmiobject使用PowerShell杀死进程

时间:2015-08-28 12:00:00

标签: powershell powershell-v3.0

需要帮助!我想使用powershell杀死特定所有者的特定(例如:iexplore)运行过程(iexplore可能由许多用户发起但我想杀死特定用户的iexplore)。

任何人都可以帮助我。提前谢谢。

2 个答案:

答案 0 :(得分:0)

你可以使用wmi类win32_process

stop-process (gwmi win32_process | ?{$_.getOwner().user -eq "username" -and $_.name -match "iexplore"} | select -expand processid) -WhatIf #remove -whatif to effectively stop the process

答案 1 :(得分:0)

或者您可以使用此代码

$UserName = “Username”
$PCName = “PCName.domain”
$ProcessName = "iexplore.exe"
(Get-WmiObject win32_process -ComputerName $PCName| where{$_.getowner().user -eq $UserName -and $_.ProcessName -eq $ProcessName}).Terminate()
相关问题