7

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:

MyCompany.MyProject.WebRole_IN_0_Web

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

2
  • 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. Jan 11, 2011 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. Jan 11, 2011 at 14:36

2 Answers 2

15

Got it:

appcmd list site /text:name

Gives you this:

MyCompany.MyProject.WebRole_IN_0_Web

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"?>
<appcmd>
    <SITE SITE.NAME="MyCompany.MyProject.WebRole_IN_0_Web" SITE.ID="1273337555" bindi
gs="https/555.555.555.555:443:" state="Started" />
</appcmd>
2

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

http://mvolo.com/configure-iis-websites-windows-azure-startup-tasks-appcmd/

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .