When I just list the sites with the default formatting, it shows the physical path.
PS C:\Windows\system32> $sm = Get-IISServerManager
PS C:\Windows\system32> $sm.Sites
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Default Web Site 1 Started %SystemDrive%\inetpub\wwwroot http *:80:
Test 2 Started C:\inetpub\wwwroot_Test http *:5007:
PS C:\Windows\system32>
But I can't find any corresponding property on the object.
$sm.Sites[0] | Format-List *
ApplicationDefaults : Microsoft.Web.Administration.ApplicationDefaults
Applications : {Default Web Site/, ...}
Bindings : {http *:80:}
Id : 1
Limits : Microsoft.Web.Administration.SiteLimits
LogFile : Microsoft.Web.Administration.SiteLogFile
Name : Default Web Site
ServerAutoStart : True
State : Started
TraceFailedRequestsLogging : Microsoft.Web.Administration.SiteTraceFailedRequestsLogging
VirtualDirectoryDefaults : Microsoft.Web.Administration.VirtualDirectoryDefaults
Attributes : {name, id, serverAutoStart, state}
ChildElements : {bindings, limits, logFile, traceFailedRequestsLogging...}
ElementTagName : site
IsLocallyStored : True
Methods : {Start, Stop}
RawAttributes : {[name, Default Web Site], [id, 1], [serverAutoStart, True], [state, 1]}
Schema : Microsoft.Web.Administration.ConfigurationElementSchema
Direct Question: How can I get the physical path of a site?
Indirect Question: Is there a way to find how the object is formatted by default? Then I could look up the Physical Path from there.
After decompiling and debugging this for a few hours, I found the expression powershell uses internally:
$_.Applications["/"].VirtualDirectories["/"].PhysicalPath
No idea how you are supposed to find that out without a decompiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With