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

后端 未结 6 1835
眼角桃花
眼角桃花 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:42

    You could create a function to stop or start the application pool remotely as below:

    function StopOrStartAppPool($RemoteServerName, $AppPoolName, $commandWebPool)
    {  
    
        if ($commandWebPool -eq "Stop")
        { 
           $wmiprocess = [wmiclass]"\\$RemoteServerName\root\cimv2:win32_process"
           $wmiprocess.create("cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs STOP_SERVER W3SVC/AppPools/$AppPoolName -s:$RemoteServerName")  
        }
        else
        {
           $wmiprocess = [wmiclass] "\\$RemoteServerName\root\cimv2:win32_process"
           $wmiprocess.create("cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs START_SERVER W3SVC/AppPools/$AppPoolName -s:$RemoteServerName")      
        }
    }
    

提交回复
热议问题