【发布时间】:2014-03-09 19:54:57
【问题描述】:
我正在尝试执行以下语句。
dir IIS:\Sites| foreach{ get-webapplication -site $_.Name} | select -first 1
这会导致
Name Application pool Protocols Physical Path
---- ---------------- --------- -------------
i1 DefaultWebSite http C:\inetpub\hosts\DefaultWebSite\i1
但是当我执行下面的结果是空的
dir IIS:\Sites| foreach{ get-webapplication -site $_.Name} | select -first 1 name
所以我查看了这个对象的属性
dir IIS:\Sites| foreach{ get-webapplication -site $_.Name} | select -first 1 | get-member | sort
Name | select Name, MemberType | format-table -auto
Name MemberType
---- ----------
applicationPool NoteProperty
Attributes Property
ChildElements Property
ClearLocalData Method
Collection NoteProperty
ConfigurationPathType NoteProperty
Copy Method
Delete Method
ElementTagName Property
enabledProtocols NoteProperty
Equals Method
GetAttribute Method
GetAttributeValue Method
GetChildElement Method
GetCollection Method
GetHashCode Method
GetMetadata Method
GetParentElement Method
GetType Method
Item ParameterizedProperty
ItemXPath NoteProperty
LoadProperties Method
Location NoteProperty
Methods Property
path NoteProperty
PhysicalPath ScriptProperty
PSPath NoteProperty
Schema Property
SetAttributeValue Method
SetMetadata Method
ToPSObject Method
ToString Method
Update Method
UpdateCollection Method
virtualDirectoryDefaults NoteProperty
所以没有“名称”属性。为什么get-webappplication可以显示name属性,但是我们不能选择呢?
【问题讨论】:
标签: powershell