Recycling IIS application pool using PowerShell: “Exception calling Recycle”

寵の児 提交于 2019-12-06 02:04:37

The original question was for IIS6, but I ran into something similar using the WebAdministration Module's Restart-WebAppPool on Windows 2012. So I dropped back to calling AppCMD, and that worked fine:

& $env:windir\system32\inetsrv\appcmd recycle apppool "YOURAPPPOOLNAMEHERE"

Sometimes, you don't have to over-engineer the solution. Hope that helps others some day.

One of the application pools was stopped, which was causing the error. The other application pools were recycling fine. The code above is ok to use for anyone else.

You can try to recycle with ADSI:

$server = "IIsServerName"  
$iis = [adsi]"IIS://$server/W3SVC/AppPools"  
$iis.psbase.children | foreach {  
    $pool = [adsi]($_.psbase.path)   
    $pool.psbase.invoke("recycle")  
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!