How to remotely stop/start an application pool in IIS 8

后端 未结 2 1052
小蘑菇
小蘑菇 2021-02-01 17:54

Caveat: using one line each!

I had these commands for use in IIS 6, and they worked just fine.

Start:

(get-wmiobject -namespace          


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-01 18:15

    To start, sometimes you need to add an explicit wait so that the app pool responds to control messages:

    Invoke-Command -ComputerName "$REMOTE_SERVER" -ScriptBlock { Import-Module WebAdministration; Start-Sleep -s 10; Start-WebAppPool -Name "$APP_POOL_NAME" }
    

    And to stop:

    Invoke-Command -ComputerName "$REMOTE_SERVER" -ScriptBlock { Import-Module WebAdministration; Stop-WebAppPool -Name "$APP_POOL_NAME" }
    

提交回复
热议问题