3
我有一些代码通过ADSI得到IIS6站点的列表:转换ADSI对象Powershell的对象
([adsi]"IIS://localhost/W3SVC").psbase.children | select servercomment, serverstate | Where-Object {$_.serverstate -ne $null}
servercomment serverstate
------------- -----------
{Default Web Site} {4}
{SharePoint Web Services} {4}
{SharePoint Central Administration v4} {4}
{SharePoint - 80} {4}
当我用管道通过的ConvertTo的cmdlet或乱串,或者使用的toString通过对象循环()我得到这样的
#TYPE Selected.System.DirectoryServices.DirectoryEntry
"servercomment","serverstate"
"System.DirectoryServices.PropertyValueCollection","System.DirectoryServices.PropertyValueCollection"
"System.DirectoryServices.PropertyValueCollection","System.DirectoryServices.PropertyValueCollection"
"System.DirectoryServices.PropertyValueCollection","System.DirectoryServices.PropertyValueCollection"
"System.DirectoryServices.PropertyValueCollection","System.DirectoryServices.PropertyValueCollection"
基本上,我只需要像PowerShell来进行治疗的站点列表(servercomment)对象,所以我可以通过各种方式导出。但从我的理解来看,这些本身就是集合,并且具有更多属性,但是当我更深入时,我没有看到任何可以提取为IIS站点名称的东西。通过WMI获取此信息更容易吗?还是必须创建一个新的Powershell对象来包含这些信息?