How to get the ManagementObjects score (WMI results) without being enumerated through a collection in .NET.
When querying a large amount of data via WMI (say the Windows event log Win32_NTLogEvent), it is very helpful to know what numbers you are getting before loading all the content. Is there a way to do this?
From what I know, there is no "Select Counter (*) FROM Win32_NTLogEvent" in WQL.
From what I know, the Count property of the ManagementObjectCollection actually lists all the results, whether the Rewindable property is true or false.
If this cannot be done in .NET, it can be done directly using the IWbem base objects Thanks
a source to share
Matching IWbem objects also return an enumeration.
For instance. IWbemServices :: ExecQuery Method returns IEnumWbemClassObject
However, see Improving Enumeration Performance for a few ideas.
It is noteworthy that WBEM_FLAG_FORWARD_ONLY
.
If you are in C # I am assuming it will call ManagementObjectSearcher with EnumerationOptions.Rewindable set to false. The default rewind is true by default, so turning it off should give some improvement.
(You can also view the profile if you want to have any performance boost if you just ask for one (key) property in your query. For example, Select RecordNumber FROM Win32_NTLogEvent
instead of Select * FROM Win32_NTLogEvent
.
In theory, not much information would need to be created, although on actually still has to list everything, and I don't remember if I ever saw an improvement from that. It's worth checking the time though.)
a source to share