IISRestart command line utility

Release 1.0 - ...

The iisrestart.exe command line utility replaces and expands Microsoft's iisreset utility. Besides iisrestart offers a lot more commands, it also e.g. executes http requests to the sites when a start command is given, effectively causing the site(s) to start and initialize.

This article gives an overview of the available commands and describes each of them in detail, including some examples. When a command includes the option of specifying a particular site (either optional or required), always specify the site's friendlyname (description column within the IIS Manager) and not the numeric identifier.

Startsite

  CopyCode image Copy Code
iisrestart /startsite <sitename>
Starts the specified site and executes http request(s) to the site:

  • Using Active Directory Service Interfaces (ADSI) the site object is retrieved and a start command is invoked on the object.
  • The smartsite.config configuration file is read to determine the ServerAddress (the address of the publication engine) and the ManagerAddress (the address of the cms engine).
  • Executes a http request to both addresses and displays the result of each request.

Sitename is required.

Stopsite

  CopyCode image Copy Code
iisrestart /stopsite <sitename>
Stops the specified site and recycles its associated application pool(s):

  • Using ADSI the site object is retrieved and a stop command is invoked on the object.
  • Again using ADSI, the application pool(s) in use by the specified site is/are determined.
  • On the application pool(s) found, a recycle command is invoked.

Sitename is required.

Start

  CopyCode image Copy Code
iisrestart /start
Invokes a regular "iisreset /start" command, followed by http requests to all local enabled Smartsite sites:

  • Invoke a "iisreset /start" command as new process (an additional command window will be opened).
  • Using ADSI the local IIS instance is searched for enabled Smartsite sites
    (State <> "Stopped" and site-folder must contain smartsite.config file).
  • For each site found, the smartsite.config file is read to determine ServerAddress and ManagerAddress.
  • Execute a http request to both of these addresses and display result.

Stop

  CopyCode image Copy Code
iisrestart /stop
Invokes a regular "iisreset /stop" command (no difference with actually issueing an "iisreset /stop" command yourself).

Status

  CopyCode image Copy Code
iisrestart /status
iisrestart /status sites:emptysix,test6
Executes http requests to specified site(s) (comma-separated) or all Smartsite sites and displays the result of each request:

  • When no sites have been specified, ADSI is used to determine the local Smartsite sites
    (site-folder must contain smartsite.config file).
  • When sites-parameter has been used, each specified site-name is checked for existence using ADSI.
  • For each checked/found site, the smartsite.config is read to determine ServerAddress and ManagerAddress and then http requests to both addresses are executed and the result written to the console window.

Recycle

  CopyCode image Copy Code
iisrestart /recycle <name>
iisrestart /recycle IIS://<machinename>/w3svc/AppPools/<name>
Recycles the specified application pool (name is required):

  • Using ADSI, the specified Application Pool object is retrieved.
  • A recycle command is invoked on the object.

To recycle a local Application Pool, just specify its name. To recycle an Application Pool on a remote machine, you must specify the full Active Directory path.

Update

  CopyCode image Copy Code
iisrestart /update sites:<name1,name2>
iisrestart /update sites:emptysix start:false stop:true 
iisrestart /update sites:<name> sourcedir:"D:\Development\New release"
Updates the local Smartsite site(s) with the specified set of assemblies:

  • If no sites have been specified, a list of local Smartsite sites is determined using ADSI.
  • If one or multiple sites have been specified using the sites command line argument (comma-separated), this list is checked and each site which could not be found will be skipped.
  • For each site a stopsite (see above) command is invoked (unless stop:false has been specified as command line argument).
  • Copies the specified set of assemblies to the bin folder of the site. When no sourcedir has been specified, the SourceDirectory application setting (as configured within iisrestart.exe.config) will be used as source directory.
  • A startsite (see above) command is invoked for the site (unless start:false has been specified).

Info

  CopyCode image Copy Code
iisrestart /info
Displays a list of all running w3wp.exe processes and their process id (pid), Application Pool ID and memory usage (both working set, which is shared memory, and private memory usage).

Sites

  CopyCode image Copy Code
iisrestart /sites
Displays a list of all local Smartsite sites configured within IIS. Using ADSI, all sites within IIS are retrieved, and when the system folder of a particular site contains a smartsite.config file, it is considered a Smartsite site. Then for each found site the basic properties are listed: sitename, IIS identifier, auto-start and the local path.

IISInfo

  CopyCode image Copy Code
iisrestart /iisinfo
iisrestart /iisinfo <name>
Displays IIS configuration and metabase properties for all sites or just the specified site (doesn't need to be a Smartsite site), such as the IIS identifier, AppFriendlyName, Path and a list of child objects (virtual directories / applications) and their properties (AppPoolId, DefaultDoc, AnonymousUserName & -Pass), including a fully-qualified ADSI-path.

Endpoints

  CopyCode image Copy Code
iisrestart /endpoints
Displays a list of all currently active WCF endpoints.
(The WMI provider for WCF must have been enabled within the web.config to be able to query the endpoints.)

Services

  CopyCode image Copy Code
iisrestart /services
Displays a list of all currently active WCF services.
(The WMI provider for WCF must have been enabled within the web.config to be able to query the services.)

Queryadsi

  CopyCode image Copy Code
iisrestart /queryadsi <path>
iisrestart /queryadsi 1668096977
iisrestart /queryadsi 1668096977/root/cms
iisrestart /queryadsi AppPools/emptysix
iisrestart /queryadsi IIS://<machinename>/w3svc/<path>
Executes the specified ADSI query and displays the properties of the object (if found).
Path is required, and when querying a site path must start with a valid numeric identifier, corresponding with an identifier as displayed within the Internet Information Services Manager. When the specified path does not start with IIS:// a local path is assumed and IIS://localhost/w3svc/ is prefixed automatically. You can use the objecttree command to get a list of valid identifiers.

Objecttree

  CopyCode image Copy Code
iisrestart /objecttree [<path>]
iisrestart /objecttree AppPoos
iisrestart /objecttree IIS://<machinename>/w3svc/AppPools
Displays the Active Directory object hierarchy of IIS, optionally starting at the specified path. When the specified path does not start with IIS:// a local path is assumed and IIS://localhost/w3svc/ is prefixed automatically.

Extendedhelp

  CopyCode image Copy Code
iisrestart /extendedhelp
Displays extended help information, including examples. Use /? or /help to get basic help information.