Querying the Battery

Welcome Forums General PowerShell Q&A Querying the Battery

This topic contains 3 replies, has 3 voices, and was last updated by

4 years, 8 months ago.

  • Author
  • #17333

    Points: 1
    Rank: Member

    Hi everyone!

    Working on a script/module that involves querying the battery (in a laptop, for the moment) via WMI. Is there any reason to use the classes in root\CIMv2 versus those in root\wmi? I ask particularly since I have seen some odd things in my testing when looking at the classes Win32_Battery and CIM_Battery, as well as a couple of other ones under root\CIMv2. Currently I'm looking at the classes in root\wmi, and I don't seem to have the same issues.

    Just looking for some thoughts.


  • #17335

    Points: 639
    Helping Hand
    Rank: Major Contributor

    With a quick search using my Google-Fu, most of the blogs\scripts are using the Win32_Battery class. There is another PowerTip that uses .NET to get battery data. If you do some research, the Win32_Classes get their information from CIM. Not sure if it's a good analogy (SQL), but the information database is CIM and the Win32_ classes are like views (compiled from one or more CIM sources). You can get some WMI information here: http://msdn.microsoft.com/en-us/library/aa394554(v=vs.85).aspx

  • #17339

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    The CIM classes are base, vendor neutral classes; when a Win32 class is provided, it usually includes more specific information pertaining to a windows computer.

    That said, no one namespace is inherently better. Namespaces are just ways of organizing classes. If you're getting better results with one class vs another, use the one that works best.

  • #17362

    Points: 1
    Rank: Member

    Rob, many thanks for those links! The PowerShell Magazine one is particularly cool.

    Don, Excellent information.. I read something somewhere about root\wmi not being "supported", but since it provides what I'm looking for better (and more consistently), I think I will stick with it. Many thanks!

The topic ‘Querying the Battery’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort