280 likes | 470 Views
CSI 277. AppCmd. AppCmd. The IIS command line administration tool. Sometimes using the GUI tool is just too much trouble!. APPCMD. General purpose IIS command line administration tool. APPCMD (command) (object-type) <identifier> < /parameter1:value1 ... > . AppCmd.
E N D
CSI 277 AppCmd
AppCmd • The IIS command line administration tool Sometimes using the GUI tool is just too much trouble!
APPCMD • General purpose IIS command line administration tool. • APPCMD (command) (object-type) <identifier> < /parameter1:value1 ... >
AppCmd • Creates and configures sites, apps, application pools, and virtual directories • Starts and stops sites, etc.
AppCmd • Also allows server administrators to build advanced management tasks simply by combining multiple AppCmdcommands, or reusing the output of the tool inside another program.
AppCmd • AppCmd.exe is located in the %systemroot%\system32\inetsrv\ directory. Because this directory is not part of your PATH automatically, you need to use the full path to the executable when executing commands like "%systemroot%\system32\inetsrv\AppCmd.exe list sites". • Alternatively, you can manually add the inetsrv directory to the path on your machine so that you can access AppCmd.exe directly from any location.
Adding to PATH • path = %PATH%;newdir
APPCMD • APPCMD /? Getting help
AppCmd • appcmd add site /? Getting more help
Command Help • The command help screen describes the syntax for a specific command and object, including the parameters it supports and examples of common tasks. To display command help: • APPCMD <COMMAND> <OBJECT> /? • For example, this command-line will display help for the LIST command of the App object: • APPCMD list app /?
AppCmd • LIST Display the objects on the machine. An optional <ID> can specify a unique object to list, or one or more parameters can be specified to match against object properties. • ADD Create a new object with the specified object properties to set during creation. • DELETEDelete the object specified by the <ID>. • SETSet parameters on the object specified by <ID>.
Supported object types: • Site • App • Vdir • Apppool • Config • Wp • Request • Module • Backup • trace
Supported Object Types ObjectDescription 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 Backup Management of server configuration backups WP Administration of worker processes Request Display of active HTTP requests Module Administration of server modules Trace Management of server trace logs
Object Help • The object help screen shows the commands supported by a specific object. • To display object help: • APPCMD <OBJECT> /? • where <OBJECT> is one of the supported object types. For example, this command-line will display help for the site object: • APPCMD site /?
Finding Objects with the LIST Command • The LIST command is the most versatile command, and is supported by all objects. The purpose of this command is to find instances of the object based on the criteria you specify. The output of this command is a list of object instances, which you can inspect by viewing their properties, export for future re-creation on another machine, or use together with another command to perform actions on them.
Listing all objects • The simplest way to use the LIST command is with no parameters, which simply lists all known instances of the object • appcmd list site object command
AppCmd • The Site object provides methods (commands) to list, create and delete sites • Try this: • appcmdlist site
AppCmd C:\Users\e6500>appcmd list site SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Unknown) SITE "frogs" (id:2,bindings:http/*:80:,state:Unknown) SITE "yadda1" (id:123,bindings:http/*.80:www.yadda1.org,state:Unknown)
AppCmd • In addition to LIST, most objects also support ADD, SET, and DELETE commands
AppCmd • APPCMD add site /? The command help screen indicates which parameters are required. For example, use this command-line to see what parameters are required
AppCmd • appcmd add site /name: string /id: uint /physicalPath: string /bindings: string appcmdadd site /name:yadda1 /id:123 /physicalPath:C:\inetpub\www\yadda1 /bindings:http/*.80:www.yadda1.org SITE object “yadda1” added APP object “yadda1/” added VDIR object “yadda1/” added
Finding Objects • %systemroot%\system32\inetsrv\appcmdlist sites • The output will be similar to: 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 object is shown on a single line, specifying its object-specific identifier (such as "Default Web Site") and one or more important properties (such as id, bindings, and state).
APPCMD list <OBJECT> <ID> • The LIST command can be used to find an instance of a specificnamed object by using a command-line in the correct form • For example, use this command to find the site with a unique id of "Default Web Site": • %systemroot%\system32\inetsrv\appcmdlist site "Default Web Site"
Listing Objects That Satisfy a Query • To find all object instances that match particular criteria, specify one or more parameters that indicate property values of the objects to match. For example, use this command-line to find all sites that are stopped: • %systemroot%\system32\inetsrv\appcmdlist sites /state:Stopped
Listing sites based on criteria • APPCMD list sites /serverAutoStart:false
AppCmd • APPCMD set site "Default Web Site" /id:200
AppCmd • APPCMD set site "Default Web Site" /? Use a form of the command help syntax to see what properties can be set on a particular object. For example, to see the properties supported by the Default Web Site
Deleting Objects • The DELETE command deletes an instance of an object. Like SET, this command also requires the object-specific identifier to be specified. For example, use this command-line to delete the site named "MyNewSite": • APPCMD delete site "MyNewSite"