API Reference
WmiReader
Simple, high-level helpers for common WMI reads (single property or arrays), with optional namespace fallback. Mirrors the simplicity of RegistryReader.
Inheritance
- Object
- WmiReader
Methods
public static IReadOnlyDictionary<String, Object> ExecClassMethod(String computer, String methodNamespace, String className, String methodName, IDictionary<String, Object> inParameters = null, CancellationToken ct = null) #IReadOnlyDictionary<String, Object>Executes a WMI class method and returns out-parameters as a case-insensitive dictionary. This is useful for static/class methods (for example MSFT_MpPreference.Set) that are invoked on the class rather than a specific instance path.
Parameters
- computer System.String
- methodNamespace System.String
- className System.String
- methodName System.String
- inParameters System.Collections.Generic.IDictionary{System.String,System.Object} = null
- ct System.Threading.CancellationToken = null
public static Task<IReadOnlyDictionary<String, Object>> ExecClassMethodAsync(String computer, String methodNamespace, String className, String methodName, IDictionary<String, Object> inParameters = null, CancellationToken ct = null) #Task<IReadOnlyDictionary<String, Object>>Executes a WMI class method and returns the raw out-parameter dictionary.
Parameters
- computer System.String
- methodNamespace System.String
- className System.String
- methodName System.String
- inParameters System.Collections.Generic.IDictionary{System.String,System.Object} = null
- ct System.Threading.CancellationToken = null
public static IReadOnlyDictionary<String, Object> ExecMethod(String computer, String methodNamespace, String objectPath, String methodName, IDictionary<String, Object> inParameters = null, CancellationToken ct = null) #IReadOnlyDictionary<String, Object>Minimal helper for special operations that require WMI instance method invocation (e.g., reading share security descriptors). Accepts an object path such as Win32_LogicalShareSecuritySetting.Name='Share' and returns out‑parameters as a case‑insensitive dictionary.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- inParameters System.Collections.Generic.IDictionary{System.String,System.Object} = null
- ct System.Threading.CancellationToken = null
public static Task<IReadOnlyDictionary<String, Object>> ExecMethodAsync(String computer, String methodNamespace, String objectPath, String methodName, IDictionary<String, Object> inParameters = null, CancellationToken ct = null) #Task<IReadOnlyDictionary<String, Object>>Executes a WMI method and returns the raw out-parameter dictionary.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- inParameters System.Collections.Generic.IDictionary{System.String,System.Object} = null
- ct System.Threading.CancellationToken = null
public static Boolean ExecOut<T1, T2>(String computer, String methodNamespace, String objectPath, String methodName, String outParameter1, String outParameter2, out Nullable<T1> value1, out Nullable<T2> value2, CancellationToken ct = null) #BooleanType Parameters
- T
- T1
- T2
Parameters
- computer String
- methodNamespace String
- objectPath String
- methodName String
- outParameter String
- value Nullable<T>
- ct CancellationToken = null
public static Task<ValueTuple<Boolean, Nullable<T1>, Nullable<T2>>> ExecOutAsync<T1, T2>(String computer, String methodNamespace, String objectPath, String methodName, String outParameter1, String outParameter2, CancellationToken ct = null) #Task<ValueTuple<Boolean, Nullable<T1>, Nullable<T2>>>Type Parameters
- T
- T1
- T2
Parameters
- computer String
- methodNamespace String
- objectPath String
- methodName String
- outParameter String
- ct CancellationToken = null
ExecOutAsync``1(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter, System.Threading.CancellationToken ct) #Executes a WMI method and extracts a single value-type out parameter.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter System.String
- ct System.Threading.CancellationToken
ExecOutAsync``2(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter1, System.String outParameter2, System.Threading.CancellationToken ct) #Executes a WMI method and extracts two value-type out parameters.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter1 System.String
- outParameter2 System.String
- ct System.Threading.CancellationToken
public static Boolean ExecOutRef<T1, T2>(String computer, String methodNamespace, String objectPath, String methodName, String outParameter1, String outParameter2, out T1 value1, out T2 value2, CancellationToken ct = null) #BooleanType Parameters
- T
- T1
- T2
Parameters
- computer String
- methodNamespace String
- objectPath String
- methodName String
- outParameter String
- value T
- ct CancellationToken = null
public static Task<ValueTuple<Boolean, T1, T2>> ExecOutRefAsync<T1, T2>(String computer, String methodNamespace, String objectPath, String methodName, String outParameter1, String outParameter2, CancellationToken ct = null) #Task<ValueTuple<Boolean, T1, T2>>Type Parameters
- T
- T1
- T2
Parameters
- computer String
- methodNamespace String
- objectPath String
- methodName String
- outParameter String
- ct CancellationToken = null
ExecOutRefAsync``1(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter, System.Threading.CancellationToken ct) #Executes a WMI method and extracts a single reference-type out parameter.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter System.String
- ct System.Threading.CancellationToken
ExecOutRefAsync``2(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter1, System.String outParameter2, System.Threading.CancellationToken ct) #Executes a WMI method and extracts two reference-type out parameters.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter1 System.String
- outParameter2 System.String
- ct System.Threading.CancellationToken
ExecOutRef``1(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter, ``0@ value, System.Threading.CancellationToken ct) #Executes a WMI method and extracts a single reference-type out parameter.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter System.String
- value ``0@
- ct System.Threading.CancellationToken
ExecOutRef``2(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter1, System.String outParameter2, ``0@ value1, ``1@ value2, System.Threading.CancellationToken ct) #Executes a WMI method and extracts two reference-type out parameters.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter1 System.String
- outParameter2 System.String
- value1 ``0@
- value2 ``1@
- ct System.Threading.CancellationToken
ExecOut``1(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter, System.Nullable{``0}@ value, System.Threading.CancellationToken ct) #Executes a WMI method and extracts a single value-type out parameter.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter System.String
- value System.Nullable{``0}@
- ct System.Threading.CancellationToken
ExecOut``2(System.String computer, System.String methodNamespace, System.String objectPath, System.String methodName, System.String outParameter1, System.String outParameter2, System.Nullable{``0}@ value1, System.Nullable{``1}@ value2, System.Threading.CancellationToken ct) #Executes a WMI method and extracts two value-type out parameters.
Parameters
- computer System.String
- methodNamespace System.String
- objectPath System.String
- methodName System.String
- outParameter1 System.String
- outParameter2 System.String
- value1 System.Nullable{``0}@
- value2 System.Nullable{``1}@
- ct System.Threading.CancellationToken
public static IReadOnlyList<T> Query<T>(String computer, String query, Func<WmiRow, T> projector, String ns = null, Boolean fallbackToDefault = false, CancellationToken ct = null) #IReadOnlyList<T>Type Parameters
- T
Parameters
- computer String
- query String
- projector Func<WmiRow, T>
- ns String = null
- fallbackToDefault Boolean = false
- ct CancellationToken = null
public static IReadOnlyList<WmiRow> QueryRows(String computer, String query, String ns = null, Boolean fallbackToDefault = false, CancellationToken ct = null) #IReadOnlyList<WmiRow>Runs a WMI query and returns rows as a lightweight WmiRow collection.
Parameters
- computer System.String
- query System.String
- ns System.String = null
- fallbackToDefault System.Boolean = false
- ct System.Threading.CancellationToken = null
public static IReadOnlyList<WmiRow> QueryRows(String computer, String query, String ns, Boolean fallbackToDefault, WmiOptions options, CancellationToken ct = null) #IReadOnlyList<WmiRow>Executes a WMI query that may return multiple rows using explicit per-call options. Returns an empty list on failure.
Parameters
- computer System.String
- query System.String
- ns System.String
- fallbackToDefault System.Boolean
- options ComputerX.Wmi.WmiOptions
- ct System.Threading.CancellationToken = null
public static async Task<IReadOnlyList<WmiRow>> QueryRowsAsync(String computer, String query, String ns = null, Boolean fallbackToDefault = false, WmiOptions options = null, CancellationToken ct = null) #Task<IReadOnlyList<WmiRow>>Asynchronously executes a WMI query that may return multiple rows. Returns an empty list on failure.
Parameters
- computer System.String
- query System.String
- ns System.String = null
- fallbackToDefault System.Boolean = false
- options ComputerX.Wmi.WmiOptions = null
- ct System.Threading.CancellationToken = null
public static IReadOnlyList<WmiRow> QueryRowsWithCredential(String computer, String query, NetworkCredential credential, String ns = null, Boolean fallbackToDefault = false, Nullable<TimeSpan> timeout = null, Nullable<Boolean> preferCimFirst = null, CancellationToken ct = null) #IReadOnlyList<WmiRow>Runs a WMI query using explicit credentials and returns rows.
Parameters
- computer System.String
- query System.String
- credential System.Net.NetworkCredential
- ns System.String = null
- fallbackToDefault System.Boolean = false
- timeout System.Nullable{System.TimeSpan} = null
- preferCimFirst System.Nullable{System.Boolean} = null
- ct System.Threading.CancellationToken = null
public static async Task<IReadOnlyList<WmiRow>> QueryRowsWithCredentialAsync(String computer, String query, NetworkCredential credential, String ns = null, Boolean fallbackToDefault = false, Nullable<TimeSpan> timeout = null, Nullable<Boolean> preferCimFirst = null, CancellationToken ct = null) #Task<IReadOnlyList<WmiRow>>Asynchronously runs a WMI query using explicit credentials.
Parameters
- computer System.String
- query System.String
- credential System.Net.NetworkCredential
- ns System.String = null
- fallbackToDefault System.Boolean = false
- timeout System.Nullable{System.TimeSpan} = null
- preferCimFirst System.Nullable{System.Boolean} = null
- ct System.Threading.CancellationToken = null
Query``1(System.String computer, System.String query, System.Func{ComputerX.Wmi.WmiRow,``0} projector, System.String ns, System.Boolean fallbackToDefault, System.Threading.CancellationToken ct) #Runs a WMI query and projects each row using the supplied delegate.
Parameters
- computer System.String
- query System.String
- projector System.Func{ComputerX.Wmi.WmiRow,``0}
- ns System.String
- fallbackToDefault System.Boolean
- ct System.Threading.CancellationToken
public static IReadOnlyList<T> ReadArrayOrEmpty<T>(String computer, String wmiClass, String property, String ns, Boolean fallbackToDefault, WmiOptions options, CancellationToken ct = null) #IReadOnlyList<T>Type Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- ns String = null
- fallbackToDefault Boolean = false
- ct CancellationToken = null
public static async Task<IReadOnlyList<T>> ReadArrayOrEmptyAsync<T>(String computer, String wmiClass, String property, String ns = null, Boolean fallbackToDefault = false, WmiOptions options = null, CancellationToken ct = null) #Task<IReadOnlyList<T>>Type Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- ns String = null
- fallbackToDefault Boolean = false
- options WmiOptions = null
- ct CancellationToken = null
ReadArrayOrEmptyAsync``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, ComputerX.Wmi.WmiOptions options, System.Threading.CancellationToken ct) #Asynchronously reads a property that may return an array. Returns an empty list on failure.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- ns System.String
- fallbackToDefault System.Boolean
- options ComputerX.Wmi.WmiOptions
- ct System.Threading.CancellationToken
ReadArrayOrEmpty``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, System.Threading.CancellationToken ct) #Reads a property across all instances of a WMI class and returns the values as a list. Non-throwing; returns an empty list on failure.
Type Parameters
- T
- Projected property type.
Parameters
- computer System.String
- Target computer name (or ".").
- wmiClass System.String
- WMI class name.
- property System.String
- Property name to read.
- ns System.String
- Optional namespace (defaults to root\cimv2).
- fallbackToDefault System.Boolean
- When true, falls back to the default namespace if the provided one fails.
- ct System.Threading.CancellationToken
- Cancellation token.
ReadArrayOrEmpty``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, ComputerX.Wmi.WmiOptions options, System.Threading.CancellationToken ct) #Reads a property across all instances of a WMI class using explicit options and returns the values as a list. Non-throwing; returns an empty list on failure.
Type Parameters
- T
- Projected property type.
Parameters
- computer System.String
- Target computer name (or ".").
- wmiClass System.String
- WMI class name.
- property System.String
- Property name to read.
- ns System.String
- Optional namespace (defaults to root\cimv2).
- fallbackToDefault System.Boolean
- When true, falls back to the default namespace if the provided one fails.
- options ComputerX.Wmi.WmiOptions
- Optional per-call WMI configuration such as timeout or credentials.
- ct System.Threading.CancellationToken
- Cancellation token.
public static T ReadProperty<T>(String computer, String wmiClass, String property, String ns, Boolean fallbackToDefault, WmiOptions options, CancellationToken ct = null) #TType Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- ns String = null
- fallbackToDefault Boolean = false
- ct CancellationToken = null
public static async Task<T> ReadPropertyAsync<T>(String computer, String wmiClass, String property, String ns = null, Boolean fallbackToDefault = false, WmiOptions options = null, CancellationToken ct = null) #Task<T>Type Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- ns String = null
- fallbackToDefault Boolean = false
- options WmiOptions = null
- ct CancellationToken = null
ReadPropertyAsync``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, ComputerX.Wmi.WmiOptions options, System.Threading.CancellationToken ct) #Asynchronously reads a single property value. Non-throwing; returns default(T) on failure.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- ns System.String
- fallbackToDefault System.Boolean
- options ComputerX.Wmi.WmiOptions
- ct System.Threading.CancellationToken
public static T ReadPropertyOrDefault<T>(String computer, String wmiClass, String property, T defaultValue, String ns = null, Boolean fallbackToDefault = false, CancellationToken ct = null) #TType Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- defaultValue T
- ns String = null
- fallbackToDefault Boolean = false
- ct CancellationToken = null
ReadPropertyOrDefault``1(System.String computer, System.String wmiClass, System.String property, ``0 defaultValue, System.String ns, System.Boolean fallbackToDefault, System.Threading.CancellationToken ct) #Reads a single property and returns a default value when not present.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- defaultValue ``0
- ns System.String
- fallbackToDefault System.Boolean
- ct System.Threading.CancellationToken
public static T ReadPropertyWithCredential<T>(String computer, String wmiClass, String property, NetworkCredential credential, String ns = null, Boolean fallbackToDefault = false, Nullable<TimeSpan> timeout = null, Nullable<Boolean> preferCimFirst = null, CancellationToken ct = null) #TType Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- credential NetworkCredential
- ns String = null
- fallbackToDefault Boolean = false
- timeout Nullable<TimeSpan> = null
- preferCimFirst Nullable<Boolean> = null
- ct CancellationToken = null
public static Task<T> ReadPropertyWithCredentialAsync<T>(String computer, String wmiClass, String property, NetworkCredential credential, String ns = null, Boolean fallbackToDefault = false, Nullable<TimeSpan> timeout = null, Nullable<Boolean> preferCimFirst = null, CancellationToken ct = null) #Task<T>Type Parameters
- T
Parameters
- computer String
- wmiClass String
- property String
- credential NetworkCredential
- ns String = null
- fallbackToDefault Boolean = false
- timeout Nullable<TimeSpan> = null
- preferCimFirst Nullable<Boolean> = null
- ct CancellationToken = null
ReadPropertyWithCredentialAsync``1(System.String computer, System.String wmiClass, System.String property, System.Net.NetworkCredential credential, System.String ns, System.Boolean fallbackToDefault, System.Nullable{System.TimeSpan} timeout, System.Nullable{System.Boolean} preferCimFirst, System.Threading.CancellationToken ct) #Asynchronously reads a single property using explicit credentials. Returns default(T) on failure.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- credential System.Net.NetworkCredential
- ns System.String
- fallbackToDefault System.Boolean
- timeout System.Nullable{System.TimeSpan}
- preferCimFirst System.Nullable{System.Boolean}
- ct System.Threading.CancellationToken
ReadPropertyWithCredential``1(System.String computer, System.String wmiClass, System.String property, System.Net.NetworkCredential credential, System.String ns, System.Boolean fallbackToDefault, System.Nullable{System.TimeSpan} timeout, System.Nullable{System.Boolean} preferCimFirst, System.Threading.CancellationToken ct) #Reads a single property using explicit credentials. Returns default(T) on failure.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- credential System.Net.NetworkCredential
- ns System.String
- fallbackToDefault System.Boolean
- timeout System.Nullable{System.TimeSpan}
- preferCimFirst System.Nullable{System.Boolean}
- ct System.Threading.CancellationToken
ReadProperty``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, System.Threading.CancellationToken ct) #Reads a single property value from the first instance of the class. Returns default(T) on failure.
Parameters
- computer System.String
- wmiClass System.String
- property System.String
- ns System.String
- fallbackToDefault System.Boolean
- ct System.Threading.CancellationToken
ReadProperty``1(System.String computer, System.String wmiClass, System.String property, System.String ns, System.Boolean fallbackToDefault, ComputerX.Wmi.WmiOptions options, System.Threading.CancellationToken ct) #Reads a single property value from the first instance of the class using explicit options. Returns default(T) on failure.
Type Parameters
- T
- Projected property type.
Parameters
- computer System.String
- Target computer name (or ".").
- wmiClass System.String
- WMI class name.
- property System.String
- Property name to read.
- ns System.String
- Optional namespace (defaults to root\cimv2).
- fallbackToDefault System.Boolean
- When true, falls back to the default namespace if the provided one fails.
- options ComputerX.Wmi.WmiOptions
- Optional per-call WMI configuration such as timeout or credentials.
- ct System.Threading.CancellationToken
- Cancellation token.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public static IWmiClient Client { get; set; } #Pluggable client implementation (WMI or CIM). Defaults to HybridWmiClient.
public static String DefaultNamespace { get; set; } #Default namespace used when none is provided. Defaults to root\cimv2.
public static Boolean AutoResolveKnownNamespaces { get; set; } #When true, attempts to map known classes to their typical namespaces if the provided one fails.