powershell - 如何获取站点的物理路径属性

标签 powershell iis

当我只列出具有默认格式的站点时,它会显示物理路径。

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> 

但是我在对象上找不到任何相应的属性。
$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

直接问题: 如何获取站点的物理路径?

间接问题: 有没有办法找到对象的默认格式?然后我可以从那里查找物理路径。

最佳答案

经过几个小时的反编译和调试,我发现powershell内部使用的表达式:
$_.Applications["/"].VirtualDirectories["/"].PhysicalPath
不知道你应该如何在没有反编译器的情况下找到它。

关于powershell - 如何获取站点的物理路径属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52498299/

相关文章:

powershell - Windows 10如何在环境变量中的系统变量中添加多个PATH?

powershell - 杀死从远程计算机上给定路径运行的多个进程

asp.net - 将查询字符串附加到 IIS 重写映射

c# - 无法让 IIS 显示 Web 应用程序

powershell - 执行AddDay时不应用日期格式

sharepoint - Powershell:使用SharePoint API,GetLocalizedString不返回任何内容

parsing - Powershell:Select-String 不解析此变量

c# - ASP.net MVC 跨应用 POST 请求

PHP @exec 悄无声息地失败了

c# - 在 IIS 中,空闲时间 20 分钟后关闭工作进程的理由是什么?