检索网站列表&使用来自C#的WMI在Windows 2008.2012服务器上托管的绑定信息 [英] Retrieve List of Websites & Binding Information hosted on windows 2008.2012 server using WMI from C#

查看:44
本文介绍了检索网站列表&使用来自C#的WMI在Windows 2008.2012服务器上托管的绑定信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取网站&网站列表使用C#中的WMI在Windows 2008,2012服务器上托管的绑定信息。

Am trying to get the list of Websites & Binding Information hosted on windows 2008,2012 server using WMI from C#.

  ConnectionOptions options = new ConnectionOptions();

                options.Authentication = AuthenticationLevel.PacketPrivacy;

                ManagementScope scope = new ManagementScope(@" \\" + machinename.ToString()。Trim()+ @" \root \WebAdministration",conn);

                scope.Connect();



                ManagementPath path = new ManagementPath("Site");



                ManagementClass Sites = new ManagementClass(s​​cope,path,null);

 ConnectionOptions options = new ConnectionOptions();
                options.Authentication = AuthenticationLevel.PacketPrivacy;
                ManagementScope scope = new ManagementScope(@"\\" + machinename.ToString().Trim() + @"\root\WebAdministration", conn);
                scope.Connect();

                ManagementPath path = new ManagementPath("Site");

                ManagementClass Sites = new ManagementClass(scope, path, null);

如何获取站点名称和绑定信息?

How do i get the site name and binding information?

问候,

Raj

Regards,
Raj

推荐答案

使用WMI Code Creator获取您需要的代码。 然后,您可以使用WMI对象来专门缩小您的需求范围。在
GitHub 上还有一个较新的WMI资源管理器可能很有用。

Use WMI Code Creator to get the code you need.  You can then play around with the WMI objects to narrow down specifically what you need. There is also a newer WMI Explorer on GitHub which could be useful.

以下
MSDN
文档提供了一个示例,说明如何枚举IIS中的应用程序并访问其名称和协议。从那里你可以使用WMI代码创建器查看其他属性并查看它们的值,这样你就可以缩小你需要的其他内容到
检索。

The following MSDN documentation has an example of how to enumerate the applications in IIS and access their name and protocols. From there you can use WMI Code Creator to view the other properties and see their values so you can narrow down what else you'll need to retrieve.

对于站点网站类有类似的数据。 Name为您提供名称,Bindings为您提供绑定信息。 Bindings是一个BindingElement数组。 BindingElement具有Protocol和BindingInformation属性,可为您提供绑定详细信息。

For sites the Site class has similar data. Name gives you the name and Bindings gives you the binding information. Bindings is an array of BindingElement. BindingElement has the Protocol and BindingInformation properties to provide you the binding details.


这篇关于检索网站列表&使用来自C#的WMI在Windows 2008.2012服务器上托管的绑定信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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