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對象來包含這些信息?