Export (0) Print
Expand All

ManagementObjectSearcher Class

Retrieves a collection of management objects based on a specified query. This class is one of the more commonly used entry points to retrieving management information. For example, it can be used to enumerate all disk drives, network adapters, processes and many more management objects on a system, or to query for all network connections that are up, services that are paused, and so on. When instantiated, an instance of this class takes as input a WMI query represented in an ObjectQuery or its derivatives, and optionally a ManagementScope representing the WMI namespace to execute the query in. It can also take additional advanced options in an EnumerationOptions. When the Get method on this object is invoked, the ManagementObjectSearcher executes the given query in the specified scope and returns a collection of management objects that match the query in a ManagementObjectCollection.

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Management.ManagementObjectSearcher

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)

'Declaration
Public Class ManagementObjectSearcher _
	Inherits Component

The ManagementObjectSearcher type exposes the following members.

  NameDescription
Public methodManagementObjectSearcherInitializes a new instance of the ManagementObjectSearcher class. After some properties on this object are set, the object can be used to invoke a query for management information. This is the default constructor.
Public methodManagementObjectSearcher(ObjectQuery)Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query for management information.
Public methodManagementObjectSearcher(String)Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query for management information.
Public methodManagementObjectSearcher(ManagementScope, ObjectQuery)Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query in the specified scope.
Public methodManagementObjectSearcher(String, String)Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query in the specified scope.
Public methodManagementObjectSearcher(ManagementScope, ObjectQuery, EnumerationOptions)Initializes a new instance of the ManagementObjectSearcher class to be used to invoke the specified query in the specified scope, with the specified options.
Public methodManagementObjectSearcher(String, String, EnumerationOptions)Initializes a new instance of the ManagementObjectSearcher class used to invoke the specified query, in the specified scope, and with the specified options.
Top

  NameDescription
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertyOptionsGets or sets the options for how to search for objects.
Public propertyQueryGets or sets the query to be invoked in the searcher (that is, the criteria to be applied to the search for management objects).
Public propertyScopeGets or sets the scope in which to look for objects (the scope represents a WMI namespace).
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Top

  NameDescription
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDisposeReleases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public methodGetInvokes the specified WMI query and returns the resulting collection.
Public methodGet(ManagementOperationObserver)Invokes the WMI query asynchronously, and binds to a watcher to deliver the results.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Top

  NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Top

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft