Push
The reason for writing the translation was the fact that, in my opinion, many Windows users are so used to the GUI that they sometimes forget about the existence of the command line. But it is the command line that allows you to automate many processes in a short period of time. Certainly the command line is not perfect, but sometimes it is this that allows you to simplify communication with those. support, and reduce kilometer screenshots, to several lines of code.
Introduction
The AppCmd command is a separate standalone tool for managing IIS 7. It implements all the basic server management functionality using a set of objects that can be controlled via the command line.
AppCmd allows you to easily manage a server without using a graphical interface and easily automates server management without writing code.
Here are the few things you can do with AppCmd:
- Create and configure sites, applications, application pools and virtual directories.
- Stop and start sites, re-launch application pool.
- Get a list of running workflows and monitor the requests that are executed.
- Search, manage, export and import IIS and ASP.NET configuration.
AppCmd also allows server administrators to easily perform complex management tasks by combining several AppCmd.exe commands, or using output in other programs.
How to use AppCmd.exe
AppCmd.exe is built on top of high-level management objects, such as a site and an application. These objects provide methods that can be used to perform various actions on these objects, and object instances provide properties for reading and tuning.
For example, a site object provides methods for outputting, creating, deleting instances of a site (these are standard methods that are present in most objects), there are still methods for starting and stopping a site. Each site instance contains properties such as name, id, etc. they can be viewed as well as searched for them. The result of each such command is always a list of object instances.
Note: AppCmd.exe is located in the
%systemroot%\system32\inetsrv\
directory. Due to the fact that this path is not registered in the PATH, you must use the full path to the command when executing, for example: "
%systemroot%\system32\inetsrv\AppCmd.exe list sites
". However, you can add this path to your PATH yourself and use the command directly from anywhere.
The command runs with one of the supported control objects and optional parameters to clarify the command:
APPCMD <COMMAND> <OBJECT> <ID> [/parameter1:value1]*
Where <COMMAND> is one of the commands supported by <OBJECT>. Most objects support a basic set of commands:
- LIST displays a list of objects. The optional <ID> can specify an object to display. One or several parameters can specify the values of the properties by which the objects will be searched.
- ADD creates a new object listing the property values that will be set at the time of creation.
- DELETE deletes the object with the specified <ID>.
- SET changes the property value to the object specified by <ID>.
Many objects support additional commands, such as START and STOP for the site.
For example, now AppCmd supports the following list of objects:
An object | Description |
---|
Site | Site management |
App | Application Management |
Vdir | Virtual Directory Management |
Apppool | Manage application pool |
Config | Configuration management |
Backup | Configuration Backup Management |
WP | Workflow Management |
Request | Manage Active HTTP Requests |
Module | Server Module Management |
Trace | Manage server trace logs |
Where <ID> is the instance ID of the object you want to specify for the command. The format of the identifier depends on the type of object. For example, for the object, site is the name of the site; for the application object, the application path is used; for the application pool, the name of the pool.
Where [/ parameter: value] * can be omitted or contain several parameters that affect the behavior of the command. Each command supports a different set of parameters, depending on the type of object. Usually, commands that search for objects, or change properties of an object, can specify property names as parameters.
The utility itself supports several parameters that affect the behavior in general, and do not depend on some types of objects. All of them are listed at the beginning of the help, which can be obtained by executing "
AppCmd.exe /?
", And contains parameters such as
/text
,
/config
and
/xml
to control the output and
/commit
to determine the level in the hierarchy, where the changes in the configuration will be tried on.
We work with help
AppCmd provides a convenient system for providing help, which can be obtained for all supported object types and commands. There are three types of help for the types of information requested.
')
general information
General information shows available objects as well as general parameters. To get general information, just dial:
APPCMD /?
Conclusion:
General purpose IIS command line administration tool. APPCMD <COMMAND> <OBJECT> <ID> < /parameter1:value1 ... > Supported object types: SITE Administration of virtual sites APP Administration of applications ...
Object Information
Object information shows a list of commands available to a particular type of object.
APPCMD <OBJECT> /?
Where
<OBJECT>
name of one of the supported objects. For example, the command for displaying information on the site object will look like this:
APPCMD site /?
Team information
Information on the command contains information on the syntax that is defined for each command, and includes the available parameters and examples of common tasks. To see this reference, run:
APPCMD <COMMAND> <OBJECT> /?
For example, to see information on the LIST command for an APP object type, run:
APPCMD list app /?
Search for objects
The LIST command is very versatile and is supported by all types of objects. The purpose of the command is to search for instances of objects by a given criterion. The output of the command is a list of instances of objects that you can view, examine the values of properties, and export them for later creation on other servers. Or use with another program to perform actions on them.
Output all objects
The simplest thing is to invoke the LIST command without parameters, this will output all instances of objects on the server:
APPCMD list <OBJECT>
For example, to view all sites on a server, use the following command.
%systemroot%\system32\inetsrv\APPCMD list sites
The output will contain the following:
SITE "Default Web Site" (id:1,bindings:HTTP/*:80:,state:Started) SITE "Site1" (id:2,bindings:http/*:81:,state:Started) SITE "Site2" (id:3,bindings:http/*:82:,state:Stopped)
By default, each following object is shown on a separate line and contains an identifier (such as the “Default Web Site”) and one or more relevant properties (such as ID, binding, and state)
Output a specific object
The LIST command can be used to search for an instance of an object with a specific object name using the following plan command
APPCMD list <OBJECT> <ID>
For example, to find a site with a unique identifier "Default Web Site", use the following line:
%systemroot%\system32\inetsrv\APPCMD list site "Default Web Site"
Object output by criterion
To find all objects that meet the specified criteria, specify one or more parameters that contain the required values for the search. For example, the following command searches for all sites that are stopped:
%systemroot%\system32\inetsrv\APPCMD list sites /state:Stopped
You can specify any number of property-value pairs, and the command will return all objects that satisfy all the specified criteria. For example, the following command will find all sites that are simultaneously stopped and at the same time configured not to start automatically.
%systemroot%\system32\inetsrv\APPCMD list sites /serverAutoStart:false /state:Stopped
Facility management
In addition to the List, most objects support the ADD, SET, and DELETE commands.
Adding a new object
The ADD command creates a new instance of the object. For example, this command creates a new site:
%systemroot%\system32\inetsrv\APPCMD add site /name:MyNewSite /bindings:"http/*:81:" /physicalPath:"C:\MyNewSite"
Depending on the object, some parameters may be required, and some may not.
If the required parameter is not specified, an error will be returned.
The help command will show which parameters are required. For example, use the following command to see which parameters are required when creating a site:
%systemroot%\system32\inetsrv\APPCMD add site /?
Modifying an existing object
The SET command changes one or more properties of the specified object instance. This command requires an object instance identifier to be specified. For example, to change the ID property of the “Default Web Site”, use the following command:
% systemroot% \ system32 \ inetsrv \ APPCMD set site "Default Web Site" / id: 200
The syntax for calling information can also be used to view a list of properties that can be changed on a specific object. For example, to see the properties supported by the "Default Web Site" type:
%systemroot%\system32\inetsrv\%systemroot%\system32\inetsrv\APPCMD set site "Default Web Site" /?
Deleting Objects
The DELETE command deletes an object instance. Like SET, this command must pass an object identifier. For example, use the following command to delete a site called “MyNewSite”:
%systemroot%\system32\inetsrv\%systemroot%\system32\inetsrv\APPCMD delete site "MyNewSite"
Backup Management
AppCmd allows you to create or restore backup copies of server configurations. You can use this to restore random changes to the server configuration, and roll back the configuration to a state in which the server was stable. It is considered good practice to make backups before changing the configuration, or installing components that change it. Each such copy contains the current ApplicationHost.config of the root configuration file, as well as other server settings, like FTP and administration tool settings.
To back up, use the BACKUP object's ADD command.
%systemroot%\system32\inetsrv\APPCMD add backup BACKUP object "20060519T172530" added
This backup with an automatically generated name, which contains the date and time of the backup.
You can also specify a specific backup name, for example, as follows:
%systemroot%\system32\inetsrv\APPCMD add backup MyBackup BACKUP object "MyBackup" added
You can view the backup list using the LIST command:
%systemroot%\system32\inetsrv\APPCMD list backups BACKUP "20060519T172530" BACKUP "MyBackup"
And finally, to restore from a backup, use the RESTORE command along with the name of the backup:
%systemroot%\system32\inetsrv\APPCMD restore backup "MyBackup" Restored configuration from backup "MyBackup"
Restore from backup stops the server and restores the full configuration as of the date when the backup was made.
In Windows 2008 and Windows Vista SP1 operating systems, AppCmd will be able to work with periodic backups performed by the system service. These backups are available in the list of all backups that were received by the AppCmd command and are available for rollback in the same way as the others.
For a detailed study of managing backups using AppCmd, you can read
here.Working with Sites, Applications, Virtual Folders and Application Pools
Creating and managing sites, applications, virtual directories are the most common tasks faced by the administrator. IIS 7 and higher adhere to a more strict hierarchy than previous versions, now the hierarchy looks like this:
- Website . The website accepts requests for a specific associated endpoint defined by the IP address and host header. For example, the following URL represents a site associated with port 81: www.mysite.com : 81
The website contains one or more applications. - Application The application is definitely in its virtual path along with the site namespace. For example, an application with a virtual path / app1 can be represented by the following URL www.mysite.com : 81 / app1
The application belongs to the application pool.
The application contains one or more virtual directories. - A virtual directory is represented by its virtual path along with the application space. For example, a virtual directory with a virtual path / vdir1 might have the following URL www.mysite.com : 81 / app1 / vdir1.
The virtual directory indicates the physical location on the disk.
This hierarchy is different from the one in IIS 6, where the Web site could contain a mixture of virtual directories and applications, and the applications were just specially marked virtual directories.
Application pool An application pool is defined by a group of settings for a workflow that performs request processing for applications in this application pool. The application pool is not part of the site-application-directory hierarchy. Each application is defined by a pool in which it will work, otherwise the application will work in the application pool defined by default.
An application pool is defined by settings such as the number of worker processes, the load version of the CLR, the type of integration, the account under which the process will be executed, and the restart settings of the process.
By default, IIS 7 and above are installed with the Default Web Site Web site, which listens on port 80, and which has no restrictions on the address and host header. The site contains a root application, and this application has a root virtual directory. There is also the application pool "DefaultAppPool", which is used as a default application pool for all applications created.
This command will display all sites, including the Default Web Site.
%systemroot%\system32\inetsrv\APPCMD list sites SITE "Default Web Site" (id:1,bindings:HTTP/*:80:,state:Started)
Let's look at the applications that belong to the Default Web Site, for this we specify the site.name property in the application output command:
%systemroot%\system32\inetsrv\APPCMD list apps /site.name:"Default Web Site" APP "Default Web Site/" (applicationPool:DefaultAppPool)
A similar command will show all the virtual directories contained in the application of "Default Web Site /", for this we specify the app.name property in the command listing virtual directories.
%systemroot%\system32\inetsrv\APPCMD list vdirs /app.name:"Default Web Site/" VDIR "Default Web Site/" (physicalPath:C:\inetpub\wwwroot)
Finally, let's review the list of application pools:
%systemroot%\system32\inetsrv\APPCMD list apppools APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started) APPPOOL "Classic .NET AppPool" (MgdVersion:v2.0,MgdMode:ISAPI,state:Started)
Creation of sites, applications, virtual directories, application pools
Now we will create a website called “MySite” and Id 2, which will listen on port 81 for all IP addresses and host headers.
%systemroot%\system32\inetsrv\APPCMD add site /name:MySite /id:2 /bindings:http/*:81: /physicalPath:C:\inetpub\mysite SITE object "MySite" added APP object "MySite/" added VDIR object "MySite/" added
The name parameter must be specified in order to create a website. The Id parameter is optional; in this case, AppCmd will generate the next available Id for the new site. We also specified the binding and the physical path, which will be described below. You can also specify additional parameters to assign values to them.
The bindings property uses the protocol / bindingInformation format, where bindingInformation is a protocol. FTP uses the following IP format: PORT: HOSTHEADER. You can specify multiple bindings using a comma for the binding between different values.
We also specified the physicalPath property for the site. Since the site itself does not have a physical path, this short form is used to create the root application, and the root virtual directory associated with the specified physical directory.
If you do not specify the physical path - the site will be created without applications; The application and virtual directory will need to be created explicitly.
Well, move on and create the following application for our site:
%systemroot%\system32\inetsrv\APPCMD add app /site.name:MySite /path:/app1 /physicalPath:C:\inetpub\mysite\app1 APP object "MySite/app1" added VDIR object "MySite/app1/" added
The team created a new virtual directory "/ app1" for the application created earlier, a virtual directory pointing to "C: \ inetpub \ mysite \ app1". The required path parameter defines the virtual path of the new application, and the required site.name parameter defines the site to which this application will belong. The optional parameter physicalPath is a short form, very similar to the one for the site, which creates the root virtual directory along with the application.
If you do not specify physicalPath, or add another virtual directory with a command such as the following:
%systemroot%\system32\inetsrv\APPCMD add vdir /app.name:"MySite/app1" /path:/vdir1 /physicalPath:C:\inetpub\mysite\app1\vdir1 VDIR object "MySite/app1/vdir1" added
then this command will create a new virtual directory, with the virtual path "/ vdir1" referring to the application created earlier and pointing to "C: \ inetpub \ mysite \ app1 \ vdir1" the required path defines the virtual path of the new virtual directory and the required app.name identifies the application to which this virtual directory will belong. The physicalPath parameter points to the physical path to which the virtual directory will be associated.
Finally, let's create a new application pool:
%systemroot%\system32\inetsrv\APPCMD add apppool /name:MyAppPool APPPOOL object "MyAppPool" added
This command creates a new application pool called MyAppPool.
For a more detailed study of sites, applications, virtual directories in IIS 7 and the various features available through AppCmd, you can contact
here.Configure sites, applications, virtual directories, and application pools.
Previously, we created a new website, added several applications and virtual directories. Now we will use AppCmd to change some properties of these objects. All AppCmd objects support the following syntax for setting properties:
APPCMD SET <OBJECT> <ID> [/property:value]*
First, let's see which applications are available on the server:
%systemroot%\system32\inetsrv\APPCMD list apps APP "Default Web Site/" (applicationPool:DefaultAppPool) APP "MySite/" (applicationPool:DefaultAppPool) APP "MySite/app1" (applicationPool:DefaultAppPool)
Remember the two applications created earlier under the MySite website. Both of these applications are configured to use the DefaultAppPool application pool. Let's change the applicationPool property of our root MySite application / so that it uses the new application pool created earlier with the name MyAppPool
%systemroot%\system32\inetsrv\APPCMD set app "MySite/" /applicationPool:MyAppPool APP object "MySite/" changed
Thus, we changed the value of the applicationPool property of our application “MySite /”, and easily transferred our application to a new application pool.
The purpose of such a transfer is that we can now change several parameters of the launch of the workflow with which our application will work, so that we can change some properties of the application pool “MyAppPool”. Before changing it is useful, look at the available properties and their current values. We can view the properties in detail like this:
%systemroot%\system32\inetsrv\APPCMD list apppool "MyAppPool" /text:* APPPOOL APPPOOL.NAME: MyAppPool managedPipelineMode: Integrated managedRuntimeVersion: v2.0 state: Started [add] name:"MyAppPool" queueLength:"1000" autoStart:"true" enable32BitAppOnWin64:"false" managedRuntimeVersion:"v2.0"<identifier> managedPipelineMode:"Integrated" passAnonymousToken:"true" [processModel] identityType:"NetworkService" userName:"" password:"" ... pingingEnabled:"true" ...
Here are some of these properties. The full list is not shown here.
We are interested in the managedRuntimeVersion property, the value of which we will change to “v1.1” in order to run our application in the application pool with asp.net v1.1. Here is this command:
%systemroot%\system32\inetsrv\APPCMD set apppool "MyAppPool" /managedRuntimeVersion:v1.1 APPPOOL object "MyAppPool" changed
You can see above that there are properties available, and some of them are nested in another element. For example, the process property is nested in processModel. If you want to change the attached property, specify it completely like this:
%systemroot%\system32\inetsrv\APPCMD set apppool "MyAppPool" /processModel.pingingEnabled:false
Other configuration items
Additionally, to control configuration properties using AppCmd objects, you can expose values to any properties in any configuration section, including those that are AppCmd objects. More on this will be discussed in the section "Working with Configuration".
getting server status
AppCmd provides an opportunity to get various information about server operation, including:
- site status
- application pool status
- active server workflows
- current requests
In addition, some objects provide commands that allow you to monitor the running time status. Commands like site object STOP, or application pool object RECYCLE.View site and application pool
The state of the site and application pool is reflected in the state property of each object. When we get a list of sites and application pools, the status is displayed on the standard output. For example:
%systemroot%\system32\inetsrv\APPCMD list apppools DefaultAppPool APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started)
The state property can be used when searching for sites or application pools that are currently in a particular state. For example, to find all running application pools: %systemroot%\system32\inetsrv\APPCMD list apppools /state:started APPPOOL "DefaultAppPool" (MgdVersion:v2.0,MgdMode:Integrated,state:Started) APPPOOL "Classic .NET AppPool" (MgdVersion:v2.0,MgdMode:ISAPI,state:Started)
View workflows
Use the WP object to get a list of running workflows. %systemroot%\system32\inetsrv\APPCMD list wp WP "3577" (apppool:DefaultAppPool)
Each WP object has an apppool.name property, which allows you to get all the workflows serving a specific application pool: %systemroot%\system32\inetsrv\APPCMD list wp /apppool.name:DefaultAppPool WP "3577" (apppool:DefaultAppPool)
Examine current queries
The Request object allows you to examine the current requests processed by the server: %systemroot%\system32\inetsrv\APPCMD list requests REQUEST "fb0000008000000e" (url:GET /wait.aspx?time=10000,time:4276 msec,client:localhost)
The list of requests can be filtered by criteria such as a site, application pool, workflow, or URL using the appropriate property as a filter.Here are some examples:
%systemroot%\system32\inetsrv\APPCMD list request /apppool.name:DefaultAppPool %systemroot%\system32\inetsrv\APPCMD list requests /wp.name:3567 %systemroot%\system32\inetsrv\APPCMD list requests /site.id:1
Work with configuration
IIS 7 and later has an XML-based hierarchical configuration system, similar to the ASP.NET configuration system, which stores the server configuration in schematized XML sections.The configuration can be at the server level in the ApplicationHost.config file or in the Web.config file that comes with the application.AppCmd allows you to fully view and change the configuration from the command line using the config object. AppCmd also provides such useful functions as reading, locking, unlocking, searching.View configuration
AppCmd works with configuration at the level of configuration sections. Each section describes server functionality and may contain one or more items and collections.The configuration can be set for any URL namespace, for example, for a site, application, or link. Configuration parameters are set at a higher level, inherited at all lower levels, unless they are redefined at lower levels.To view the effective configuration for a specific level, use the LIST command of the Config object, for example: %systemroot%\system32\inetsrv\APPCMD list config <URL> /section:SectionName
where <URL> is the configuration path to be read. For example, "Default Web Site /" or "Default Web Site / app1 / hello.html". If nothing is specified, the server level configuration will be read.For a detailed study of the hierarchy and how to build a configuration for use with AppCmd and in other programs, you can read here .The section parameter indicates the section to be read. If you do not specify, then the entire configuration will be displayed, acting at the specified URL. For example, the following command will show the entire configuration applied for the Default Web Site root application: %systemroot%\system32\inetsrv\APPCMD list config "Default Web Site/"
To show a specific section and use the following command: %systemroot%\system32\inetsrv\APPCMD list config "Default Web Site/" /section:aspx <system.webServer> <asp> <session /> <comPlus /> <cache /> <limits /> </asp> </system.webServer>
By default, AppCmd shows a configuration that is explicitly set. If you want to see the calculated configuration, including the inherited configuration, specify the / config: * parameter %systemroot%\system32\inetsrv\APPCMD list config "Default Web Site/" /section:asp /config:*
To view the list of available sections use the following command: %systemroot%\system32\inetsrv\APPCMD list config /section:?
Editing configuration properties
In AppCmd, each section is represented by a configuration object that contains properties that correspond to the configuration section. Use the SET command to change these properties. The syntax is:APPCMD set config <URL> /section:SectionName [ /property:value ]+
<URL> is an optional parameter; it defines the configuration path to which these changes will be applied. If not specified, the changes will be applied at the server level. And will be inherited by all other URLs.The section parameter is required, it defines the section to be edited.For example, you can set the appAllowClientDebug property of the asp section for localhost / app1 as follows: %systemroot%\system32\inetsrv\APPCMD set config "http://localhost/app1" /section:asp /appAllowClientDebug:false CONFIG object "asp" changed
You can set the property nested under the element of the configuration section using this element with the path specified: %systemroot%\system32\inetsrv\APPCMD set config "http://localhost/app1" /section:asp /limits.requestQueueMax:4000 CONFIG object "asp" changed
Specify several properties on the same command line to edit several values at once within the same section.To view all the properties that can be edited within one section, use the command: %systemroot%\system32\inetsrv\APPCMD set config /section:asp /?
Note: the asp section is closed for editing by default, so executing this command will return a lock violation error. But you can first remove the lock by adjusting the configuration at the server level, omitting <URL>, or transfer them to the place of the server level tags using /commit: apphost
. See the configuration control layout later in the article.Editing configuration collections
AppCmd provides the ability to edit configuration collections. A configuration collection can contain several elements — for example, the system.webServer/modules
section contains a list of modules that will be executed on the server.To change a property in a list item, you need to concretize the collection item using the item index, along with an indication of the path. An index is an expression that uses the value of keys to point to a specific item in a collection. The index has the following format: The[key1='value1',key2='value2',...]
number of keys required to specify a particular element depends on the type of collection, but in most cases one is enough.For example, to change the type of a property on a collection item with the key name equal to "FormsAuthentication" run: %systemroot%\system32\inetsrv\APPCMD set config /section:system.webServer/modules /[name='FormsAuthentication'].type:System.Web.Security.FormsAuthenticationModule
To add a new item to the collection, add a "+" sign to the beginning of the item name. Instead of an index, list the values for each property. And yet, non-key properties can also be included in the collection index. For example, you can add a new item to the list of modules: %systemroot%\system32\inetsrv\APPCMD set config /section:system.webServer/modules /+[name='MyModule',type='MyType']
To remove an item from the list - it is necessary to indicate at the beginning the "-" %systemroot%\system32\inetsrv\APPCMD set config /section:system.webServer/modules /-[name='MyModule']
Control of setting location
The configuration system is hierarchical, and allows changes to be recorded at various levels starting from the server level ( ApplicationHost.config
), ending with the provided file of web.config
the site, application, virtual directory.When a change is written to any level, this change is inherited by all URLs that are lower than this level. For example, a change made to the Web.config
root site will be applied to the entire site.By default, AppCmd writes changes at the level that was selected for the change. For example, if you change the value for "Default Web Site /," the change will be written to the Web.config file located in the root of the site.However, it is possible to change it at a higher level, and apply this change on a set of URLs using the location tag. For example, an application may contain a configuration that is applicable on one of the application directories. AppCmd provides this capability using the commit parameter.The commit parameter can have the following values:- (omitted) is the default value, changes are applied at the same level at which they are set.
- The url is the same as the default.
- site - changes are written to the root web.config of the site
- app - changes are written to the root of the application in Web.config.
- apphost - changes are written at the server level in applicationHost.config
- <PATH> - changes are written to the specified file.
For example, this command will disable the ability to view the contents of the directory in the application and record the changes at web.config
the site level: %systemroot%\system32\inetsrv\APPCMD set config http://localhost/app1/ /section:directoryBrowse /enabled:false /commit:site
You can read more about configuring IIS and storing changes here .Locking and unlocking configuration
The configuration system allows you to block a section on one of the levels, preventing them from changing at lower levels. This can be used to prevent the application from changing the settings that the administrator wants to apply on the entire server.By default, most of the IIS settings are exposed, for editing at the server level. To be able to edit them, you need to open them. AppCmd provides this feature: %systemroot%\system32\inetsrv\APPCMD unlock config /section:asp
and vice versa, to close the possibility of changes: %systemroot%\system32\inetsrv\APPCMD lock config /section:asp
Keep in mind that when you close a section, some applications may already have changes in that section, which will result in an error accessing a section that is closed.Configuration Search
AppCmd can search in the presented hierarchy of configurations for all sections in which a particular property changes or has a specified value. The ability to search for a configuration can be used to search for any function that has been enabled, or to make sure that the requirements of the current environment are met.Find on the server all the places where the configuration is defined as follows: %systemroot%\system32\inetsrv\APPCMD search config
To search for all places for a given configuration path where the settings of a given site change, add a path: %systemroot%\system32\inetsrv\APPCMD search config "Default Web Site/"
In order to find all the configurations where the given section changes: %systemroot%\system32\inetsrv\APPCMD search config "Default Web Site/" /section:directoryBrowse
To find the places where the value of a specific section property changes: %systemroot%\system32\inetsrv\APPCMD search config "Default Web Site/" /section:directoryBrowse /enabled
Finally, to find all the places where the property is set to the specified value: %systemroot%\system32\inetsrv\APPCMD search config "Default Web Site/" /section:directoryBrowse /enabled:true
Work with output
You mentioned earlier that the output of the LIST command is a list of object instances. AppCmd allows you to use different types of output that allow you to control the level of detail on the output objects.Standard output
Let's see the output of the LIST command for sites. By default, AppCmd uses a compact output format: %systemroot%\system32\inetsrv\APPCMD list sites SITE "Default Web Site" (id:1,bindings:HTTP/*:80:,state:Started) SITE "Site1" (id:2,bindings:http/*:81:,state:Started) SITE "Site2" (id:3,bindings:http/*:82:,state:Stopped)
With this output, each object is displayed in one line, and contains information about the type (SITE), identifier ("Default Web Site"). Several common or important properties are also found in the output (id, bindings, and state of the site object)Detailed output
Most objects support significantly more properties than those found in standard output. To view all the properties of an object, you must specify the text: * parameter, and the properties of each instance will appear in the tree format: APPCMD list site "Default Web Site" /text:* SITE SITE.NAME: Default Web Site SITE.ID: 2 bindings: http/*:80: state: Started ...
In the example above, the output was truncated, the actual output contains many more lines.Output for other command line utilities
AppCmd provides the ability to display only the value of a given property, each instance. Set the property value in the text: parameter. For example, the following command will return the virtual directories of all applications, show only the physicalPath property of each element: %systemroot%\system32\inetsrv\APPCMD list vdirs /text:physicalPath C:\inetpub\wwwroot C:\inetpub\vdir1 D:\vdir2
Of course, you can show any specific property of the listed object types.Sometimes very successfully, you can use the output of AppCmd with other existing commands and shell commands, such as for and findstr.exe. These commands work better if the objects of interest are located on a separate line.As an example, imagine a command that generates the contents of each IIS virtual directory. This command requires a list of physical paths of each virtual directory to be entered, and execute DIR, each such directory to use FOR to loop through them. FOR /F %f IN ('%systemroot%\system32\inetsrv\APPCMD list vdir /text:physicalPath') DO CALL DIR %f
Configuration output
Objects contain configuration data that is part of the corresponding configuration section. The Config object is the main example of this, and is the usual wrapper over the IIS configuration system. Any object returned by the config command is a configuration section. Other objects, such as a site, contain configuration information in the form of their properties.If you want to display the configuration information of the returned objects in XML format - use the config parameter. To show the XML configuration for the site, use: %systemroot%\system32\inetsrv\APPCMD list site "Default Web Site" /config <site name="Default Web Site" id="1"> <bindings> <binding protocol="HTTP" bindingInformation="*:80:" /> ...
XML output
The command also maintains its own xml output format, which generates the generated xml for the objects returned by the command. This opens up interesting possibilities for us, which distinguishes from all other command line utilities presented to us earlier by the IIS team.- . , AppCmd, . .
- . (, 10 000 ) - , . XML, .
- Export data to other programs. The AppCmd XML data format allows them to be used in other programs for processing or creating reports. For example, AppCmd can be used with xslt conversion to generate an html report, import it into SQL server for further processing, or use ADO.NET for program processing.
The following command lists the sites in xml format: %systemroot%\system32\inetsrv\APPCMD list sites /xml
For more in-depth study you can read here.Total
In this review, we introduced you to various actionable commands available in the AppCmd IIS 7 and higher command.You can also get acquainted with various ways of managing the server using the command line here.