在 WMI 中,我可以使用联接(或类似的东西)来获取站点的 IisWebServer 对象(给定服务器名称和部署位置)
给定服务器名称和物理路径,我希望能够找到 IISWebServer 对象和 ApplicationPool。网站 url 也是可接受的输入。
我们的技术是 IIS 6、WMI 以及通过 C# 或 Powershell 2 进行访问。我确信使用 IIS 7 其托管 API。我们还没有那个。
我可以执行以下操作:
从 IISWebVirtualDirSetting 并过滤(离线)匹配的物理路径。
$theVirtualDir = gwmi -Namespace "root/MicrosoftIISv2" `
-ComputerName $servername -authentication PacketPrivacy `
-class "IISWebVirtualDirSetting" `
| where-object {$_.Path -like $deployLocation}
从虚拟目录对象中,我可以获得一个名称(例如 W3SVC/40565456/root)。有了这个名字,我就可以得到其他好东西,例如 IIS Web 服务器对象。
gwmi -Namespace "root/MicrosoftIISv2" `
-ComputerName $servername `
-authentication PacketPrivacy `
-Query "SELECT * FROM IisWebServer WHERE Name='W3SVC/40589473'"
问题重述:
1) 这是一种查询语言。我可以加入或子查询以便 1 个 WMI 查询语句获取基于 IISWebVirtualDir.Path 的 Web 服务器吗?如何?
2) 在解决问题 1 时,您必须解释如何查询 Path 属性。为什么这是一个无效的查询? “从 IISWebVirtualDirSetting WHERE Path='D:\sites\globaldominator' 中选择 *”
Given a server name and a physical path, I'd like to be able to hunt down the IISWebServer object and ApplicationPool. Website url is also an acceptable input.
Our technologies are IIS 6, WMI, and access via C# or Powershell 2. I'm certain this would be easier with IIS 7 its managed API. We don't have that yet.
Here's what I can do:
Get a list of IIS virtual directories from IISWebVirtualDirSetting and filter (offline) for the matching physical path.
$theVirtualDir = gwmi -Namespace "root/MicrosoftIISv2" `
-ComputerName $servername -authentication PacketPrivacy `
-class "IISWebVirtualDirSetting" `
| where-object {$_.Path -like $deployLocation}
From the virtual directory object, I can get a name (like W3SVC/40565456/root). Given this name, I can get to other goodies, such as the IIS web server object.
gwmi -Namespace "root/MicrosoftIISv2" `
-ComputerName $servername `
-authentication PacketPrivacy `
-Query "SELECT * FROM IisWebServer WHERE Name='W3SVC/40589473'"
The questions, restated:
1) This is a query language. Can I join or subquery so that 1 WMI query statement gets web servers based on IISWebVirtualDir.Path? How?
2) In solving 1, you'll have to explain how to query on the Path property. Why is this an invalid query? "SELECT * FROM IISWebVirtualDirSetting WHERE Path='D:\sites\globaldominator'"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 WQL 中,没有 JOIN 运算符。您需要通过将两个查询保存到变量并进行一些后处理来做到这一点。但是,对于第二个问题,您需要转义反斜杠。这将是
In WQL, there isn't a JOIN operator. You will need to do that by saving both queries to a variable and do some post processing. However, for your second question, you need to escape the backslashes. It would be