Use the Command Line with IIS 7.0

10/10/2010 9:42:50 AM
The following are some of the command-line administrative tools you can use and their benefits:
  • PowerShell:

    • Object-oriented data handling

    • Namespaces

    • Pipelining

    • Transparent access to command-prompt commands

    • Trusted scripts

  • AppCmd:

    • Exposing key IIS Server management functionality

    • Easily controlling the server without using a GUI

    • Automating management tasks without writing code

In this article we focus on the Appcmd.exe utility, which is specifically designed to be used for IIS 7.0 management. Appcmd.exe can be found in the %systemroot%\system32\inetsrv directory. The following is a list of supported object types that you can configure using this tool:

  • SITE: Administration of virtual sites

  • APP: Administration of applications

  • VDIR: Administration of virtual directories

  • APPPOOL: Administration of application pools

  • WP: Administration of worker process

  • REQUEST: Administration of HTTP requests

  • BACKUP: Administration of server configuration backups

  • MODULE: Administration of server modules

  • TRACE: Working with failed request trace logs


You can add the %systemroot%\system32\inetsrv directory to your path environment variables to be able to run Appcmd.exe from any location.

The object that is being used defines the types of commands available for the object. To see what commands are available and a brief description of what the commands will do for a specific object, you can use appcmd <object> /?. For example, to see what commands are available for the APPPOOL object, follow these steps:

Open a command prompt.

Navigate to the inetsrv directory by typing CD\windows\system32\inetsrv.

Type appcmd apppool /?. The available commands are now listed for the APPPOOL object:

  • List: List the application pools.

  • Set: Configure the application pool.

  • Add: Add a new application pool.

  • Delete: Delete the application pool.

  • Start: Start the application pool.

  • Stop: Stop the application pool.

  • Recycle: Recycle the application pool.

You can customize your command further by using an optional parameter such as the following:

  • /?: Display help either from appcmd or appcmd <object>.

  • /text<:value>: Generate output in text format.

  • /xml: Generate output in XML format.

  • /in or-: Read and operate on XML input from standard input.

  • /config<:*>: Show configuration for displayed objects.

  • /metadata: Show configuration metadata when displaying configuration.

  • /commit: Set the path where configuration changes are saved.

  • /debug: Show debugging information for command execution.


To see more details for these parameters, type appcmd.exe /?.

So now that you have a basic understanding of appcmd.exe, let’s take a look at how we can use it. First let see how we can get a list of the websites on our server:

Type appcmd list site.

A new line appears for each website, as shown in Figure 1, with the following details:

  • Name of the site

  • ID

  • Bindings

  • State

Figure 1. Results displayed from list sites.

Now let’s take a look at how to add, configure, and remove a site:

Add a Website Using appcmd.exe

To add a website, you need to provide some configuration parameters for the site. Here’s what you do:

Type the following:

appcmd add site /name:NewSite /bindings:"http/*:802:" /physicalpath:"c:\NewSite"

The command returns three lines:

object "NewSite" added
APP object "NewSite/" added
VDIR object "NewSite/" added

If desired, check in IIS Manager and confirm that the new website has been created.

Configure a Website Using appcmd.exe

Here’s how you reconfigure the port setting from 802 to 82 on the site you just created:

Type the following:

appcmd set site "NewSite" /bindings:"http/*:82:"

When the command prompt is returned to you, the task is complete.

If desired, you can check the bindings in IIS Manager to confirm the changes.

Delete a Website Using appcmd.exe

The website you have created will have a short life. You are now going to delete it:

Type appcmd delete site "NewSite". The command returns SITE object "NewSite" deleted.

Refresh the view in IIS Manager to confirm that the website NewSite has been deleted.

Now let’s take a look at backing up and restoring the web server configuration.

Back Up Your Configuration

To back up your configuration, type appcmd add backup “Backup config”. (If no name parameter is provided the backup will automatically generate a name, based on a timestamp.) The command returns BACKUP object “backup_config” added.

View Available Configuration Backups

To view available configuration backups, type appcmd list backup. The command returns a list of all available backups of your configuration, including any backups that VSS automatically created.

Restore Configuration Backups

To restore configuration backups, type appcmd restore backup “backup config”. This command returns Restored configuration from backup “backup config”.

Using appcmd.exe can ease the burden of managing your IIS environment. Being able to run many management tasks from a command line means that you will be able to script these tasks and schedule them as needed.

Most View
Dell Insporon 14R 5421 Touch - Touchscreen Laptop With Durable Battery (Part 1)
MSI GX60 Review - Radeon HD 7970M In A $1,200 Gaming Notebook (Part 9)
Samsung Chromebook - Is It Worth The Value Equation (Part 3)
6 Best New Things To Do With Raspberry Pi (Part 1)
The JauBird BlueBuds X - Wireless Comforts For Yuppies
TaskPaper - Completely Rethinks Lists
Corsair Force Series GS 240GB - Blessed With Toggle-Mode NAND
17 Killer Mac Apps Under $20 (Part 4) : Typeit4me, ReadKit, Doo document organizer
Haswell Ultrabooks Shootout Featherweight Battle Royale (Part 3) - Sony VAIO Pro 13, Toshiba PORTEGE Z30
Olympus M.Zuiko Digital ED 75-300mm f/4.8-6.7 II Lens Review
Top 10
Sharepoint 2013 : Farm Management - Disable a Timer Job,Start a Timer Job, Set the Schedule for a Timer Job
Sharepoint 2013 : Farm Management - Display Available Timer Jobs on the Farm, Get a Specific Timer Job, Enable a Timer Job
Sharepoint 2013 : Farm Management - Review Workflow Configuration Settings,Modify Workflow Configuration Settings
Sharepoint 2013 : Farm Management - Review SharePoint Designer Settings, Configure SharePoint Designer Settings
Sharepoint 2013 : Farm Management - Remove a Managed Path, Merge Log Files, End the Current Log File
SQL Server 2012 : Policy Based Management - Evaluating Policies
SQL Server 2012 : Defining Policies (part 3) - Creating Policies
SQL Server 2012 : Defining Policies (part 2) - Conditions
SQL Server 2012 : Defining Policies (part 1) - Management Facets
Microsoft Exchange Server 2010 : Configuring Anti-Spam and Message Filtering Options (part 4) - Preventing Internal Servers from Being Filtered