WMI - IIS 7 - Retrieve All Website Bindings

I am trying to find sample code that shows how to use WMI (using C #) to request remote IIS 7 for all website bindings. I cannot make the heads or tails of all the classes / namespaces and queries that need to be done for this. If the sample code is missing, I would like some illustrations to be good documents.

Thank you so much

+3
source share
2 answers

To connect to an external IIS instance, you need to use the function ServerManager.OpenRemote("serverName"). (See the msdn article here .)

serverManager.Sites, site.Bindings Site, , -.

+1

, IIS, System.DirectoryServices.

, , .

:

using System.DirectoryServices

// Assuming your Server Id is 1, and you are connecting to your local IIS.
DirectoryEntry de = new DirectoryEntry(@"IIS://localhost/W3SVC/1/Root");
foreach (DirectoryEntry entry in de.Children)
{
   foreach (PropertyValueCollection property in entry.Properties)
   {
      Console.WriteLine("Name: {0}, Value {1}",property.PropertyName, property.Value);
   }
}
+1

Source: https://habr.com/ru/post/1790488/


All Articles