How to get site physical path with appcmd

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 /site.name:"$siteName" /config | Get-PipelineInput
    }

This also worked for me. running cmd as admin.

appcmd list app /site.name:"Default Web Site" /path:"/" /xml | appcmd list vdir /in /text:physicalPath

source