我想知道是否有人可以向我解释我所看到的行为差异。
我正在尝试查找 IIS 站点的物理路径。
该示例有效,正确返回PhysicalPath
Import-Module WebAdministration
Get-ChildItem iis:\\sites | Select PhysicalPath
Run Code Online (Sandbox Code Playgroud)
该示例不起作用。PhysicalPath 返回为 null/空。
Get-IISSite | select PhysicalPath
Run Code Online (Sandbox Code Playgroud)
如果我是正确的,两个样本都应该返回一个Microsoft.Web.Administration.Site对象。为什么第二个缺少数据?
让我们来看看:
Get-ChildItem iis:\sites | 获取会员 | 其中名称类似 p* | 排序-对象名称
TypeName: System.Object
Name MemberType Definition
---- ---------- ----------
password NoteProperty string password=
physicalPath NoteProperty string physicalPath=C:\inetpub\wwwroot
PSChildName NoteProperty string PSChildName=Default Web Site
PSDrive NoteProperty PSDriveInfo PSDrive=IIS
PSIsContainer NoteProperty bool PSIsContainer=True
PSParentPath NoteProperty string PSParentPath=WebAdministration::\\SANKNIGHT\Sites
PSPath NoteProperty string PSPath=WebAdministration::\\SANKNIGHT\Sites\Default Web Site
PSProvider NoteProperty IIsProviderInfo PSProvider=WebAdministration
Run Code Online (Sandbox Code Playgroud)
获取-IISSite | 获取会员
TypeName: Microsoft.Web.Administration.Site
Name MemberType Definition
---- ---------- ----------
ApplicationDefaults Property Microsoft.Web.Administration.ApplicationDefaults ApplicationDefault...
Applications Property Microsoft.Web.Administration.ApplicationCollection Applications {get;}
Attributes Property Microsoft.Web.Administration.ConfigurationAttributeCollection Attri...
Bindings Property Microsoft.Web.Administration.BindingCollection Bindings {get;}
ChildElements Property Microsoft.Web.Administration.ConfigurationChildElementCollection Ch...
Delete Method void Delete()
Run Code Online (Sandbox Code Playgroud)
它没有任何以 P 开头的成员,并且成员数量比 Get-ChildItem 少得多。您可以看到它们也不是同一个对象。
使用 Get-ChildItem 时,每个提供程序都会提供一些有关应显示内容的提示。我认为这是在:
$pshome\Modules\WebAdministration\iisprovider.format.ps1xml
因此,添加了所有额外信息。
| 归档时间: |
|
| 查看次数: |
7986 次 |
| 最近记录: |