I have a scenario where a process is stuck every single Monday morning because of an Oracle database so I tried creating a PowerShell script to run every Monday but regardless of getting an error or not, the process remains.
The line I'm attempting to use for the "kill" is:
Get-Process -Name ez0* -ComputerName $server | Stop-Process -Force
Tried doing this locally as well without the -ComputerName
.
I'm not getting any errors from this line with or without the -Force
it just executes and moves on.
Just doing Get-Process
works and I can see it but I can't end it with PowerShell. After many attempts I remotely logged on to the server and just right-clicked the process and chose "End task" which worked just fine.
It is an odd process because it's one out of initial 8 (based on cores) and when you stop the service, all but one of the processes is removed save for the one that is hung.
Taskkill allows you to kill a process either by its PID or by the name listed for it in the tasklist output. To stop a process by its ID, use taskkill /F /PID <PID> , such as taskkill /F /ID 312 7 if 3127 is the PID of the process that you want to kill.
To end a Windows PowerShell session in a Command Prompt window, type exit . The typical command prompt returns.
To kill the process in Windows, you can use Task Manager, Command Prompt, or Windows Powershell. By using Task Manager, select the process and hit the “End Task” button to kill the process. You can kill the process with Command Prompt by specifying PID or Image name in the “taskkill” command.
Try using:
$termproc = (get-wmiobject -ComputerName $server -Class Win32_Process -Filter "name like 'ez0%'"
$termproc.terminate()
You could also just do the below if you don't want to check the processes in the variable first.
(get-wmiobject -ComputerName $server -Class Win32_Process -Filter "name like 'ez0%'").terminate()
Thanks, Tim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With