IIS 7 Command Line Tool ======================= `AppCmd.exe` IIS 7 command-line tool used to perform common IIS administrative tasks such as creating new sites, stopping/starting services, and viewing status of the site. ## Usage appcmd (command) (object-type) In order to run `AppCmd.exe`, you will either need to change directory into `%windir%\system32\inetsrv\` or add it to your `PATH` variable. On a *Windows 2008* server with a default installation, `AppCmd.exe` is located in `C:\Windows\System32\inetsrv`. **Supported object types**: - `SITE` Administration of virtual sites - `APP` Administration of applications - `VDIR` Administration of virtual directories - `APPPOOL` Administration of application pools - `CONFIG` Administration of general configuration sections - `WP` Administration of worker processes - `REQUEST` Administration of HTTP requests - `MODULE` Administration of server modules - `BACKUP` Administration of server configuration backups - `TRACE` Working with failed request trace logs **General parameters**: /? Display context-sensitive help message. /text<:value> Generate output in text format (default). /text:* shows all object properties in detail view. /text: shows the value of the specified attribute for each object. /xml Generate output in XML format. Use this to produce output that can be sent to another command running in /in mode. /in or - Read and operate on XML input from standard input. Use this to operate on input produced by another command running in /xml mode. /config<:*> Show configuration for displayed objects. /config:* also includes inherited configuration. /metadata Show configuration metadata when displaying configuration. /commit Set config path where configuration changes are saved. Can specify either a specific configuration path, "site", "app", "parent", or "url" to save to the appropriate portion of the path being edited by the command, "apphost", "webroot", or "machine" for the corresponding configuration level. /debug Show debugging information for command execution. > Use `!` to escape parameters that have same names as the general parameters, like `/!debug:value` to set a config property named `debug`. ## Prerequisites (as per Windows 2012 Core) Install IIS (powershell): install-windowsfeature web-server Install IIS remote management (this renders the rest quite moot): Install-WindowsFeature Web-Mgmt-Service Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 Net Stop WMSVC Net Start WMSVC netsh advfirewall firewall add rule name="Allow Web Management" dir=in action=allow service="WMSVC" Register ASP.NET features for WCF if needed: dism /online /enable-feature /featurename:IIS-ASPNET45 /all Register ASP.NET features for WCF if needed: dism /Online /Enable-Feature /FeatureName:WAS-WindowsActivationService /all dism /Online /Enable-Feature /FeatureName:WAS-ProcessModel /all dism /Online /Enable-Feature /FeatureName:WAS-NetFxEnvironment /all dism /Online /Enable-Feature /FeatureName:WAS-ConfigurationAPI /all dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation /all dism /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation45 /all Install telnet client (always handy for debug): dism /online /enable-feature /featurename:TelnetClient Open firewall ports (use when needed): netsh advfirewall firewall add rule name="WebPort" dir=in protocol=TCP localport=8080 action=allow ## Examples ### List List all sites: appcmd list sites List started sites: appcmd list sites /state:started List stopped sites: appcmd list sites /state:stopped List unknown sites: appcmd list sites /state:stopped ### Start and Stop Start a site: appcmd start sites "Default Web Site" Stop a site: appcmd stop sites "Default Web Site" ### Add appcmd add site /name:mywebsite /id:99 /bindings:http/*:81 /physicalPath:C:\mywebsite ### Configuration List all backup configurations: appcmd list backup Show site configuration: appcmd list site "Default Web Site" /config List site properties to set: appcmd set site "Default Web Site" -? Set a property: appcmd set site "Default Web Site" -propertyName:"Some Value" E.g. change binding: appcmd set site "Default Web Site" -bindings:"http://*:8888" ### Application Pools: Add: appcmd add apppool /name:"My App Pool" /managedRuntimeVersion:v4.0 /managedPipelineMode:Classic appcmd add apppool /name:"My App Pool" /managedRuntimeVersion:v2.0 /managedPipelineMode:Classic appcmd add apppool /name:"My App Pool" /managedRuntimeVersion:v4.0 /managedPipelineMode:Integrated List: appcmd list apppool List apps and their app pools: appcmd list app Assign app pool to an app: appcmd set app "APPNAME/" -applicationPool:"My App Pool" ### Installing a certificate You need the pfx file. certutil -p -importPFX C:\Certificates\MyCertificate.pfx netsh http add sslcert ipport=0.0.0.0:443 certhash= appid={} --- **Author** - Jon LaBelle, - original version - Marco Mastropaolo - added app pools management **Resources** - [Appcmd.exe (IIS 7)](http://technet.microsoft.com/en-us/library/cc772200.aspx) - [Getting Started with AppCmd.exe](http://learn.iis.net/page.aspx/114/getting-started-with-appcmdexe/) - [Configuring IIS 7 from the command line using Appcmd.exe (Part 1)](http://www.windowsnetworking.com/articles-tutorials/windows-server-2008/Configuring-IIS-7-command-line-Appcmdexe-Part1.html) - [How to use the Appcmd.exe command-line tool](http://support.microsoft.com/kb/930909)