I have some code to get a list of IIS6 sites through ADSI:
([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}
When I pipe it through the convertto cmdlets or out-string or looping through objects using tostring() I get something like this
#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"
Basically I just need the list of sites (servercomment) to be treated like Powershell objects so I can export them through various means. But from my understanding these are collections in themselves and do have more properties, but when I go deeper I don't see anything that can be extracted as the name of an IIS site. Is getting this info through WMI easier or do I have to create a new Powershell object to contain these?