1

Need help! I want to kill the particular (ex: iexplore ) running process for particular owner ( iexplore may initiated by many users but I want to kill the iexplore for particular user ) using powershell.

can any one help me on this. Advance thanks.

Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103

2 Answers2

1

Or you can use this code

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

you can use the wmi class 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

Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
  • 1
    Thanks for the reply. when i run this , i am getting the error. Exception calling "GetOwner" : "Not found " At line:1 char:38 + stop-process (gwmi win32_process | ?{$_.getOwner().user -eq "gssmboop" -and $_.n ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WMIMethodException – Manikandan Boopathi Aug 28 '15 at 14:48