Get Physical root of Web application

26/01/2012 11:43

$server = "localhost"
$url="https://yoursiteurl.com"
$siteName = (get-spWebApplication $url).DisplayName

$iis = [ADSI] "IIS://$server/W3SVC"
$site = $iis.psbase.children | where {$_.schemaClassName -eq "IIsWebServer" -AND $_.ServerComment -eq $siteName}
$path = $site.psbase.children | where {$_.name -eq 'root'}
$path.path

 

#Another approach is throug powershell IIS drive, you have to import module

#get web.config path

$iisSiteName="Your site name in central administration"
import-module WebAdministration
$webConfigPath=(get-childitem iis:\sites |where-object {$_.Name -eq $iisSiteName}).PhysicalPath
$webConfigPath