Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

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

2 Answers 2

up vote 3 down vote accepted

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>
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:

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.

share|improve this answer

Your Answer

 
discard

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.