Well, taking the simplest approach here and filtering based on the properties returned from your example, I would rather use the site id part in the Name property:
Get-WmiObject IIsWebVirtualDir -namespace "ROOT\MicrosoftIISv2" | ` Where-Object { $_.name -like "W3SVC/1/*" }
The above example shows only the virtual directories on the default website that was configured when IIS was first installed. It always has identifier 1.
Note: the backtick `after the line is a line continuation character (actually it is an escape character, but I avoid EOL), like _ in Visual Basic. I use this, so the ugly horizontal scrollbars do not appear in the code above.
-Oisin
source share