Getting all virtual directories for a IIS6 web site using WMI

后端 未结 1 1951
忘掉有多难
忘掉有多难 2021-01-21 12:43

I want to list all virtual directories that belong to a web site with a certain name using WMI and PowerShell.

I know I can list all virtual directories on a server usin

1条回答
  •  失恋的感觉
    2021-01-21 13:35

    Well, taking the simplest approach here and filtering based on the properties returned from your given example, I would probably opt to use the site identifier portion in the Name property:

    Get-WmiObject IIsWebVirtualDir -namespace "ROOT\MicrosoftIISv2" | `
         Where-Object { $_.name -like "W3SVC/1/*" }
    

    The above example only shows virtual directories on the default website that is set up with IIS first install. This always has the identifier 1.

    Note: the backtick ` after the bar is the line continuation character (actually it's the escape character, but I'm escaping the EOL,) like _ in Visual Basic. I'm using this so the ugly horizontal scrollbars don't show up in the code block above.

    -Oisin

    0 讨论(0)
提交回复
热议问题