__EventConsumer, ROOT\Microsoft\SqlServer\ComputerManagement12, c# samples

Class | Methods | Properties (3) | Qualifiers (1) | Instances | Namespaces (142)
Samples: VB Script | C# | VB.Net | Search on:Microsoft

c# Code samples

The class __EventConsumer is abstract and serves only as a base for new classes.

WMI query - sample windows WQL with C#, CreatorSID property of __EventConsumer

Short C# sample code to get the abstract class __EventConsumer and its properties.
See in another language: VBScript, VB.Net.
	//https://wutils.com/wmi/
	
	//Project -> Add reference -> System.Management
	//using System.Management;
	
	//set the class name and namespace
	string NamespacePath = "\\\\.\\ROOT\\Microsoft\\SqlServer\\ComputerManagement12";
	string ClassName = "__EventConsumer";
	
	//Create ManagementClass
	ManagementClass mClass = new ManagementClass(NamespacePath + ":" + ClassName);
	
	// List the properties in the __EventConsumer class
	PropertyDataCollection lproperties = mClass.Properties;
	
	// display the properties  
	Console.WriteLine(string.Format("Property Names in {0}: ",ClassName));
	foreach (PropertyData property in lproperties)
	{
	    Console.WriteLine("name: {0}, Origin: {1}", property.Name, property.Origin );
	}	
	

WMI query - list of class instances

List of all instances of __EventConsumer class in C#.
See in another language: VBScript, VB.Net.
	//https://wutils.com/wmi/
	
	//Project -> Add reference -> System.Management
	//using System.Management;
	
	//set the class name and namespace
	string NamespacePath = "\\\\.\\ROOT\\Microsoft\\SqlServer\\ComputerManagement12";
	string ClassName = "__EventConsumer";
	
	//Create ManagementClass
	ManagementClass oClass = new ManagementClass(NamespacePath + ":" + ClassName);
	
	//Get all instances of the class and enumerate them
	foreach (ManagementObject oObject in oClass.GetInstances())
	{
		//access a property of the Management object
		Console.WriteLine("CreatorSID : {0}", oObject["CreatorSID"]);
	}
	
comments powered by Disqus
WUtils.com