Skip to main content

Did you know appcmd commands

Did you know appcmd commands


Application Pools
1. Recycle all application pools (replace recycle with start/stop to start/stop all apppools)appcmd list apppool /xml | appcmd recycle apppool /in
2. Stop application pools with word "cheap" in it
appcmd list apppool /name:"$=*cheap*" /xml | appcmd stop apppool /in


3. Set property enable32BitAppOnWin64 to true for all apppools (Filter apppools as in 2 if needed)
appcmd list apppool /xml | appcmd set apppool /in /enable32BitAppOnWin64:true

4. Start apppools which are stopped
appcmd list apppool /state:Stopped /xml | appcmd start apppool /in

5. Recycle application pools which are used in some applications
appcmd list app /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
appcmd list app /xml | appcmd recycle apppool /in (This might recycle one apppool multiple times)

6. Recycle apppools serving website “Default Web Site”
appcmd list site "Default Web Site" /xml | appcmd list app /in /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in
appcmd list app /site.name:"Default Web Site" /xml | appcmd list apppool /in /xml | appcmd recycle apppool /in


Sites
7. Start all the sites (Replace start with stop to stop all sites)
appcmd list site /xml | appcmd start site /in

8. Start the sites which are stopped
appcmd list site /state:stopped /xml | appcmd start site /in

9. Set serverAutoStart to false for all sites
appcmd list site /xml | appcmd set site /serverAutoStart:false /in

10. Keep sites config data and restore later
appcmd list site /config /xml > sites.xml
appcmd add sites /in < sites.xml


Applications and Vdirs
11. Delete all apps which are using a particular apppool
appcmd list apppool DefaultAppPool /xml | appcmd list app /in /xml | appcmd delete app /in

12. Move all applications in a site to NewAppPool apppool
appcmd list app /site.name:"Default Web Site" /xml | appcmd set app /in /applicationPool:NewAppPool

13. List all sites with "/test" app
appcmd list app /path:"/test" /xml | appcmd list site /in

14. List apps created by user10 (assuming all his apps under a folder whose name contains user10)
appcmd list vdir /physicalPath:"$=*user10*" /xml | appcmd list app /in

15. List sites which read from C:\inetput\wwwroot
appcmd list vdir /physicalPath:C:\inetput\wwwroot /xml | appcmd list app /xml /in | appcmd list site /in

16. List the vdirs of sites which are stopped
appcmd list site /state:stopped /xml | appcmd list app /xml /in | appcmd list vdir /in

Worker processes and Requests
17. Stop apppools of requests running for more than 60 seconds
appcmd list request /xml /time:"$>60000" | appcmd list apppool /in /xml | appcmd stop apppool /in

18. List apps served by wp 3600
appcmd list wp 3600 /xml | appcmd list apppool /xml /in | appcmd list app /in

Modules
19. Disable all managed modules
appcmd list module /preCondition:managedHandler /xml | appcmd delete module /in

20. Uninstall all native modules
appcmd list module /type:"" /xml | appcmd uninstall module /in

21. Unlock all module entries under system.webServer/modules (won’t work on vista)
appcmd list module /xml | appcmd set config /lockItem:false /in

Configuration
22. Keep config of a particular section and restore later
appcmd list config http://localhost/app1/ /section:caching /xml /config > config.xml
appcmd set config 
http://localhost/app1 /in < config.xml

Backups and Traces23. Delete all backups
appcmd list backup /xml | appcmd delete backup /in

24. List sites generating 404
appcmd list trace /statusCode:404 /xml | appcmd list site /in


References: This is a local copy of an article from http://goo.gl/fGvOYc

Comments

Popular posts from this blog

Internet Information Services(IIS) reveals its real or internal IP Address

In the ever changing world of global data communications, inexpensive Internet connections, and fast-paced software development, security is becoming more and more of an issue. Security is now a basic requirement because global computing is inherently insecure.

Keeping that in mind, we recently ran our flagship product through a security audit. It was such a helpful exercise in tying-off any remaining lose ends in our application in terms of application security. 
Based on the security audit report, there was a relatively minor issue that appeared when accessing the /images directory of our application. Turns out that the Location response header of the 301 request returns an Internal IP address. The issue is detailed below.

Issue reportedInternet Information Services (IIS) may reveal its real or internal IP address in the Location header via a request to the /images directory. The value returned whilst pen testing is https://10.0.0.10/images.

The riskInformation regarding internal IP add…

IIS Request Filtering to block HTTP Verbs (For example Trace)

The issueRequest Filtering is a built-in security feature that was introduced in Internet Information Services (IIS) 7.0. This can be used to block specific verbs like "Trace".

When request filtering blocks an HTTP request, IIS 7 will return an HTTP 404 error to the client and log the HTTP status with a unique substatus that identifies the reason that the request was denied. Verb Denied.

HTTP SubstatusDescription404.5URL Sequence Denied404.6Verb Denied404.7File Extension Denied404.8Hidden Namespace404.1Request Header Too Long404.11URL Double Escaped404.12URL Has High Bit Chars404.13Content Length Too Large

Unit Testing HttpContext.Current.Session in MVC3 .NET

We recently changed some functionality where during the "CREATE" process, we go through a wizard to save application data. This data is saved only to the session in the final step when the user clicks the final submit.

This was easy enough to implement but when I started writing unit tests for my static methods that Add, Update, Delete or Modify the contents of our application data in the session, I got the following error:
System.NullReferenceException: Object reference not set to an instance of an object.

Turns out I had forgotten to setup the HttpContext.
The following "TestInitialise" method fixed my problem :)

[TestInitialize]
public void TestSetup()
{
// We need to setup the Current HTTP Context as follows:

// Step 1: Setup the HTTP Request
var httpRequest = new HttpRequest("", "http://localhost/", "");

// Step 2: Setup the HTTP Response
var httpResponce = new HttpResponse(new StringWriter());

// Step 3: Se…