I work with several customers that release highly anticipated information on the web sites on specific days of the month and anticipation of the load, some of the customers recycle the application pool for the application to start out with a minimal memory footprint.
In order to recycle the application pools, the customers were logging into each server and opening the IIS Manager console (run –> intemgr), selecting the application pool, and recycling. This is a tedious exercise when there are 20+ servers in the farm.
We implemented the following command as the customers utilizes Web Deploy for application and web deployments and the following script can be run from a single workstation to remotely recycle the application pool using the sync verb and the –source is recycleApp:
msdeploy.exe -verb:sync -source:recycleApp -dest:recycleApp="WebSite1/Application",computername=10.0.0.15
In a sync operation, specify recycleApp for both the source and dest arguments and in the dest argument, specify the application path and any provider settings. If the target server is remote, include the computername parameter in the dest argument.
A batch file can be created with the IP address of each server as a line in the file. Or, a PowerShell script could be created to loop a list of servers and send the command to each server in the list.
Please note, the Web Deployment service must be running on the remote server and the logged in user must be a member of the administrator group. Instructions on how to allow a non-administrator to recycle the application pools are listed in this blog post: http://blogs.msdn.com/b/asiatech/archive/2011/07/21/iis-7-delegate-remote-application-pool-recycling-for-non-administrator.aspx
There are two options when logged onto the server with the first being the appcmd utility:
appcmd list app /site.name:"WebSite1/Application" /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
and the second option is the Web Deploy utility
msdeploy.exe -verb:sync -source:recycleApp="WebSite1/Application" -dest:recycleApp="WebSite1/Application"
More detail on the recycleApp provider is found here http://technet.microsoft.com/en-us/library/ee522997(v=WS.10).aspx
Use the appcmd list wp command to verify the application pool has recycled before and after the recycle to see the PID changing. Or, update the settings in the application pool to log the manual recycle action in the System Event log file.