Manage IIS Using Appcmd

Introduction

The appcmd.exe is a single command, used to manage IIS 7 and above. It is used to manage the Server without using a graphical administration tool. The appcmd is located in C:\Windows\System32\inetsrv (%systemroot%\system32\inetsrv\) directory. By default, it will not add into environment variable. 

Key Features 

  • Creating and configuring the sites.
  • To list the running worker process.
  • Backup and restoring the site configuration.
  • Retrieve the information about the Application pools.

Object Types

  • List
  • Add
  • Delete
  • Set
  • Hide
Syntax  
  1. appcmd <objecttypes> <parameters>   
  2. set path=%path%;%systemroot%\system32\inetsrv; //used to set the environment variable   

To list all the sites, use the command, given below:

  1. appcmd list sites     
To get the details of a specific site binding and status (stopped/start), use the command, given below:
  1. appcmd list site "Default web site"   
To list all the sites, which had been stopped, use the command, given below:
  1. appcmd list sites /state:Stopped   
To add a new site, use the command, given below:
  1. appcmd add site /name:"added using appcmd" /bindings:"http/*:81:localhost" /physicalPath:"D:\test"  
To add an https binding to the site, use the command, given below:
  1. appcmd set site /site.name:"added using appcmd" /+bindings.[protocol='https',bindingInformation='127.0.0.1:444:localhost']    
To list all the applications, use the command, given below:
  1. Appcmd list app  
To change an application pool, use the command, given below:
  1. appcmd set app "added using appcmd/app1" /applicationPool:appcmdpool  
To view the application pool details including the username and password of the app account, use the command, given below:
  1. appcmd list apppool "MyAppPool" /text:*  
Backup
  1. appcmd add backup   
  2. appcmd add backup "locahostbkup"  
  3. appcmd list backup   
  4. appcmd delete backup "backup name"  
Restore
  1. appcmd restore backup "locahostbkup "  
  2. appcmd restored configuration from backup "locahostbkup"  
To view the list of the worker process, which will help us to attach the debugger in Visual Studio, use the command, given below:
  1. appcmd list wps  
To view the list of the physical path, use the command, given below:
  1. appcmd list vdirs /text:physicalPath   
To start and stop the sites, use the command, given below:
  1. appcmd start site "Default web site"  
  2. appcmd stop site "Default web site"
Ebook Download
View all
Learn
View all