Start/Stop App Pool IIS6.0 with Powershell or command line

后端 未结 6 1837
眼角桃花
眼角桃花 2021-01-12 17:48

I\'m using IIS 6.0 and looking for a way to stop/start the app pool. I know there is a stop-appPool for powershell in 7.0 but using 6.0. :-( So does anyone have a powersh

6条回答
  •  感动是毒
    2021-01-12 18:38

    Ok here it is, I just add a switch to stop the app pool else it starts since no harm in starting an app pool that is already started:

    param([string]$appPoolName, [switch]$stop)
    
    $appPool = get-wmiobject -namespace "root\MicrosoftIISv2" -class "IIsApplicationPool" | where-object {$_.Name -eq "W3SVC/AppPools/$appPoolName"}
    
    if($appPool)
    {
       if($stop)
       {
          $appPool.Stop()
       }
       else
       {
          $appPool.Start()
       }
    }
    

提交回复
热议问题