Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 powershell script or another command line exe that will stop/start the app pool?

Thanks.

like image 218
Bruce227 Avatar asked Feb 11 '10 21:02

Bruce227


People also ask

How do I Auto Start IIS application pool?

Configuring Auto-Start with IIS ManagerIn the Connections pane, select the Application Pools node, revealing the Application Pools pane in the main view. Select the application pool for which you wish to enable Auto-Start. Locate the Start Mode option under the General group and set it to AlwaysRunning. Click OK.

How do I stop all application pools?

How to Stop Application Pools Using the IIS Manager. On the Connections pane, expand the server node and click Application Pools to display all Application Pools. On the Application Pools page, select the application pool for the published application that is running. Click Stop to stop the application pool.


2 Answers

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()
   }
}
like image 170
Bruce227 Avatar answered Nov 15 '22 08:11

Bruce227


If anybody is looking for a purely command-line tool that does not require Powershell, I have created such a thing based on the information contained in these other answers. Since the original question is specifically looking for possible command-line alternatives, I thought I would share it here.

Usage is quite simple:

IIS6AppPool Start DefaultAppPool
IIS6AppPool Stop AppPool #1
IIS6AppPool Recycle Some other app pool

Source and binaries are available on bitbucket. May this save somebody else a few minutes of head scratching.

like image 38
Chris Nielsen Avatar answered Nov 15 '22 08:11

Chris Nielsen