Read-WmiObject

Execute a simple WMI query.


Settings:

  • Namespace
    Specifies the namespace to which the connection is to be made and in which the class (object) is located. This value is also set using the WMI browser. The default namespace is \\.\root\CIMV2.
  • Object path
    This is the relative path within the namespace and corresponds to the class name for which the number of existing instances on the system is to be determined. This value is also set using the WMI browser.
  • Query
    The query specifies a criterion (similar to the WHERE clause in the SQL query) that must be met. If this criterion matches a found instance of the specified class, the properties of this instance are used. However, it is not a result set that is returned, but only the first instance to which this criterion matches. Currently, only the equals sign is supported as a criterion. This value is also set via the wizard in the Enter Search Key dialog.

  • Variable prefix
    Together with the property names, this entry results in the actual variable name, i.e. the prefix is placed in front of the variable name.
  • Properties
    Names of properties selected in the WMI Browser. Each line together with the variable prefix results in a variable. The value of the variable is determined at runtime when the script is executed.


Example:

The following example searches the CIMV2 namespace for all instances of the class Win32_LogicalDisk where the Caption property has the value C:. The values of the properties FreeSpace and Size are then read from these instances and stored in variables of the same name that begin with the prefix _WMI. The result is the capacity of drive C: in the variable _WMISize, the current free space in the variable _WMIFreeSpace:


Corresponds to DSM eScript command:

  • WMISimpleQuery


See also: