How to get IIS AppPool Worker Process ID

后端 未结 3 1639
情深已故
情深已故 2020-12-13 05:08

I have a PowerShell script that is run automatically when our monitoring service detects that a website is down. It is supposed to stop the AppPool (using Stop-WebAppP

3条回答
  •  臣服心动
    2020-12-13 05:51

    In case that Process ID is really the id of process to kill, you can:

    $id = dir IIS:\AppPools\MyAppPool\WorkerProcesses\ | Select-Object -expand processId
    Stop-Process -id $id
    

    or

    dir IIS:\AppPools\MyAppPool\WorkerProcesses\ | % { Stop-Process -id $_.processId }
    

提交回复
热议问题