Skip to main content

Use the WebAdministration module's Get-WebFilePath cmdlet to get an IIS site, application, or virtual directory physical path.

Import-Module WebAdministration

# -----------------------------------------------------------------------------
# Get-WebFilePath
# Gets the physical path to the location of the specified IIS module.
# https://learn.microsoft.com/en-us/powershell/module/webadministration/get-webfilepath
# -----------------------------------------------------------------------------

# Get-WebFilePath returns a System.IO.DirectoryInfo object (https://learn.microsoft.com/en-us/dotnet/api/system.io.directoryinfo)

# Get the physical path of the default website
PS > (Get-WebFilePath -PSPath "IIS:\Sites\Default Web Site").FullName
C:\inetpub\wwwroot\tech0.local\public

# Get the physical path of an application with a website
PS > (Get-WebFilePath -PSPath "IIS:\Sites\Default Web Site\MyApp").FullName
C:\inetpub\wwwroot\test

# Get the physical path of a virtual directory within a website
PS > (Get-WebFilePath -PSPath "IIS:\Sites\Default Web Site\virtual-directory").FullName
C:\inetpub\virtual-directory