使用WMI获取IIS6网站的所有虚拟目录 [英] Getting all virtual directories for a IIS6 web site using WMI

查看:73
本文介绍了使用WMI获取IIS6网站的所有虚拟目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用WMI和PowerShell列出具有特定名称的网站的所有虚拟目录.

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 using the code below, but how can I filter out only those that belong to a specific site?

Get-WmiObject IIsWebVirtualDir -namespace "ROOT\MicrosoftIISv2"

推荐答案

在这里,采用最简单的方法并根据给定示例返回的属性进行过滤,我可能会选择在Name属性中使用站点标识符部分:

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/*" }

上面的示例仅显示使用IIS首次安装设置的默认网站上的虚拟目录.它始终具有标识符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.

注意:竖线后的反引号`是换行符(实际上是转义符,但我要转义EOL),就像Visual Basic中的_一样.我正在使用它,所以丑陋的水平滚动条不会出现在上面的代码块中.

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

这篇关于使用WMI获取IIS6网站的所有虚拟目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆