Reputation: 189
I wonder how you can write a batch file or powershell script that, given an input of a user name, that it goes and kill every processes that is owned by that user.
For example, if I input user name: testuser. I want the script to go and kill every system processes that its owner is testuser.
On a Windows Server 2008, 2012.
Thanks.
Upvotes: 0
Views: 2215
Reputation: 189
use the command taskkill on windows server, you can kill any processes owned by specific user.
TASKKILL /F /FI "USERNAME eq "
Upvotes: 1
Reputation: 4078
Using powershell
you can list all processes started by a specified user:
Get-Process -IncludeUserName | where {$_.UserName -eq "<Username here>"}
To kill/stop a process, either call .kill()
on each result or feed the result into Stop-Process
.
Upvotes: 0