I need help with killing child process but keep parent safe. I'm new to powershell scripting [obviously]. Here's exactly what I need:
I have processes that are using more than 500 000K of memory and I want to put them down by script that will run daily. But in the same time I want to avoid killing parent process which can also fall in the "above 500 000" category. I want to use it for something else but as an example I'm showing iexplore.exe tree.
Two of child processes are breaching my memory max. I'm able to kill those by script, but I need to put fail safe option in case parent process will also go above specified limit and that I'm not sure how to aproach.
This is what I have so far. First step is to get all breaching processes:
Get-WmiObject -ComputerName $[list of servers] Win32_Process -Filter "name = '[app name]'" | Select-Object __Server,Name,@{Name='WorkingSet';Expression={[math]::Round(($_.WS/1MB),2)}},@{Name='VirtualMemory';Expression={[math]::Round(($_.VM/1MB),2)}} | Where-Object {$_.WorkingSet -gt $[my threshold]}
Next step would be to stop them.
I would be grateful for any hints.
Jules
No comments:
Post a Comment