ADSIを介してIIS6サイトのリストを取得するためのコードがいくつかあります。
([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コマンドレットまたはout-stringを介してパイプするか、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"
基本的に、サイトのリスト(servercomment)をPowershellオブジェクトのように扱う必要があるので、さまざまな方法でそれらをエクスポートできます。しかし、私の理解では、これらはそれ自体がコレクションであり、より多くのプロパティがありますが、深く掘り下げると、IISサイトの名前として抽出できるものは何も表示されません。WMIを介してこの情報を取得するのは簡単ですか、それともこれらを含む新しいPowershellオブジェクトを作成する必要がありますか?