Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I run the following command on my server:

%windir%\system32\inetsrv\AppCmd.exe list site

I get this output:

SITE "MyCompany.MyProject.WebRole_IN_0_Web" (id:1273337555,bindings:https/555.555.555.555:443:,state:Started)

How can I get just the site name:


Is some kind of nasty string parsing my only option? The server is a Windows Azure instance.

share|improve this question
why you need that? You need to put that string in a text file or similar things? In this case, consider to use shell script to manipulate strings. – Nicola Boccardi Jan 11 '11 at 14:15
@Nicola Because it's created dynamically I can't hard-code it, so I need to get it as a variable that I can use in my batch file for some configuration I need to make. – tjrobinson Jan 11 '11 at 14:36
up vote 5 down vote accepted

Got it:

appcmd list site /text:name

Gives you this:


The help describes how this works:

/text<:value>    Generate output in text format (default).
                 /text:* shows all object properties in detail view.
                 /text:<attribute> shows the value of the specified
                 attribute for each object.

I worked out that name was the correct attribute by calling:

appcmd list site /xml

Which returns in XML format (including attribute names):

<?xml version="1.0" encoding="UTF-8"?>
    <SITE SITE.NAME="MyCompany.MyProject.WebRole_IN_0_Web" SITE.ID="1273337555" bindi
gs="https/555.555.555.555:443:" state="Started" />
share|improve this answer

If you are looking to configure the site/application pool using an AppCmd startup task, check out my recent post about this:

This covers how to find the site/application pool to edit, and also how to run the task AFTER the site/apppool configuration is created and not before.

Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.