Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I am trying the following appcmd commnad:

appcmd list app /"" /xml | appcmd list vdir /in /text:physicalPath is a correct site name in IIS. appcmd is registered in path;

I get the following error output when I am trying to execute a command in cmd.exe:

ERROR ( hresult:8007000d, message:The input contained an error element, which may indicate that the operationproducing the input has failed. )

What is the mistake in the app setup? I guess I am mixing a cmd and powershell approach, but the abocementioned script doesn't work in PowerShell either. A PowerShell way of getting the path by web site name is preferable.

P.S. My PowerShell alternative that also doesn't work:

$appCmd = "$Env:SystemRoot\system32\inetsrv\appcmd.exe"

$appcmd list app /"" /xml | $appcmd list vdir /in /text:physicalPath


share|improve this question
up vote 3 down vote accepted

Researched myself and found an solution:

     function GetPhysicalPath ([String]$siteName) {

        function Get-PipelineInput
            end {
                [xml]$appConfigXml = $input
                return $appConfigXml.application.virtualDirectory.physicalPath

        $appCmd = "$Env:SystemRoot\system32\inetsrv\appcmd.exe"  

        return & $appCmd list app /"$siteName" /config | Get-PipelineInput
share|improve this answer
If this was the solution, please accept it as the answer. – Ryan Gates Dec 3 '13 at 21:33
Nice solution. Have to be careful though, since appcmd list app ... will return all virtual directories as siblings i.e. it will break the XML parser. If you're only interested in the root of the site, better to use "vdir" $appCmd list vdir "$siteName/" /config (note the trailing slash on site name), and then tweak the xml path to suit i.e. $appConfigXml.virtualDirectory.physicalPath – Dave Transom May 28 '15 at 4:07

You must log in to answer this question.

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