CoderJony

Get physical path of an IIS website using PowerShell

Below piece of code will give you physical path of an IIS website.

Import-Module WebAdministration

[string] $iisWebsiteName = 'Default Web Site'

$iisWebsite = Get-WebFilePath "IIS:\Sites\$iisWebsiteName"

if($iisWebsite -ne $null)
{ 
    Write-Output "Website's physical path:"
    Write-Output $iisWebsite.FullName
}
else
{
    Write-Output "Website not found"
} 

See below image:

enter image description here

Buy Me A Coffee