Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Error calling get-wmiobject for Win32_powerplan

I’m trying to return the Win32_PowerPlan in PowerShell 7 on Windows 11 with the following code:

get-wmiobject -namespace "root\cimv2\power" -class Win32_powerplan

However, I get the output:

get-wmiobject : 
At line:1 char:1
+ get-wmiobject -namespace "root\cimv2\power" -class Win32_powerplan
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Error Log Outuput

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not sure what could be going on or how to get better error logs. The official docs use this exact code snippet, so not sure what it should change to if it’s wrong.

Potentially related to PowerShell call to Win32_PowerPlan showing invalid class error

>Solution :

It would appear that, to retrieve the information you are seeking, PowerShell needs to be run in "elevated" mode (i.e., "Run as Administrator").

When doing so, I see the information as intended; however, when running ‘normally’ (even though I’m logged on with admin rights), I see the same error message that you have reported.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading