Configuring Remote Execute Action to Restart IIS Application Pools in Applications Manager

Configuring Remote Execute Action to Restart IIS Application Pools in Applications Manager

Info
This KB contains the steps to configure remote action for restarting IIS Application Pools in Applications Manager.

Steps to Configure Remote Execute Action in Applications Manager

  1. Extract the attached 'RestartIISAppPools.zip' file on the remote server.
    1. Ensure the extracted file is placed in an accessible location on the remote server.
  2. Copy the absolute path of the extracted file. (Ex: C:\Users\Administrator\RestartIISAppPools.bat)
    1. This path will be used in step 4.d while configuring the execution action.
  3. Open the batch file and replace 'DefaultAppPool' with the specific IIS app pool name that needs to be restarted.
  4. Go to Applications Manager, click on Actions () drop down under the navigation menu and click on Execute Program () and follow the steps below:
    1. Specify the Display Name (Ex: Restart App Pools).
    2. Script Location: Remote Server
    3. Target Hosts: Add a new host or choose existing one.
    4. WarningEnsure the user used to add the host have enough privilege to restart the Application Pools.
    5. Program To Execute: Absolute path copied in step 2.
    6. Directory to execute Program: C:\ or the path to execute the program.
    7. Configure Success notification or Failure notification as per the need.
    8. Click Create Action () button.

Verify if an Application Pool is restarted

To check whether the IIS Application Pool has restarted, run the following PowerShell command.
Quote
Get-WinEvent -LogName System | Where-Object {$_.Message -like "recycle*"}

Command used

Use the following appcmd command to restart an IIS Application Pool. Replace <APP_POOL_NAME> with the required application pool name (Ex: DefaultAppPool).
To restart single application pool:
Quote
appcmd recycle apppool /apppool.name:<APP_POOL_NAME>

To restart multiple application pool: (Edit and append the lines in the extracted bat file)
Quote
appcmd recycle apppool /apppool.name:<APP_POOL_1_NAME>
appcmd recycle apppool /apppool.name:<APP_POOL_2_NAME>
...........
appcmd recycle apppool /apppool.name:<APP_POOL_N_NAME>
Notes
If the appcmd path is not set in the environment variable, navigate to %windir%\system32\inetsrv to execute the command.

                  New to ADSelfService Plus?