Kill Process with powershell

All,
I have a w3wp.exe process that occassionally rolls out of control. I first wanted to know if there was anyway to limit the amount of memory a process can take and kill itself if it hits that limit?
Second - Can a script be written that constantly runs that will check the w3wp process and if its over a certain amount of memory utilized- kill it.
There are multiple w3wp process running but whenever I kill the one that barells out of control everything is fine for a period of time. Then we eventually run into the same issue where we have to manually kill process.

Anyone have an idea why this is happening? Were assuming its something to do with Sharepoint and IIS7 which are both running on this server.

Thanks!!
k3vsmithAsked:
Who is Participating?
 
Justin SmithConnect With a Mentor Sr. System EngineerCommented:
SOrry....it's the Recycle settings you should look for.  You can tell it to auto-restart when it hits a certain memory level....
0
 
Justin SmithSr. System EngineerCommented:
Each app pool in IIS has an associated w3wp worker process.

You can limit them memory on these things by going into IIS and editing the properties of the app pools.

Common cause of out of control memory is bad code or a bad web part.
0
 
k3vsmithAuthor Commented:
Thanks for your quick response!
Can you describe how to edit the properties of the app pools.
I see the application pools in IIS manager but I dont know what to edit to limit memory utilization.
0
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
Im no IIS Expert, but the below I think should work bearing in mind what you originally asked for :)

Get-Process w3wp.exe | Stop-Process
Wait-Process w3wp.exe -timeout 10
Start-Process w3wp.exe
0
 
k3vsmithAuthor Commented:
That worked. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.