satoukum
satoukum

Reputation: 1258

Powershell call to Win32_PowerPlan showing invalid class error

How do I get this Powershell command working? Does this mean something on my non-working machine is corrupted? What would be some steps to solve?

Command on non-working/broken machine:

PS> Get-CimInstance -Class "Win32_PowerPlan" -Namespace "root\cimv2\power"

Get-CimInstance : invalid class
At line:1 char:1
+ Get-CimInstance -Class "Win32_PowerPlan" -Namespace "root\cimv2\power ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo            : MetadataError: (root\cimv2\power:win32_PowerPlan:String) [Get-CimInstance, CimException
    + FullyQualifiedErrorId   : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

Command on working machine:

PS> Get-CimInstance -Class "Win32_PowerPlan" -Namespace "root\cimv2\power"

Caption        :
Description    : Automatically balances performance with energy consumption on capable hardware.
ElementName    : Balanced
InstanceID     : Microsoft:PowerPlan\{1234-guid-abc-1}
IsActive       : True
PSComputerName :

Caption        :
Description    : Favors performance, but may use more energy.
ElementName    : High performance
InstanceID     : Microsoft:PowerPlan\{1234-guid-abc-2}
IsActive       : False
PSComputerName :

Caption        :
Description    : Saves energy by reducing your computer’s performance where possible.
ElementName    : Power saver
InstanceID     : Microsoft:PowerPlan\{1234-guid-abc-3}
IsActive       : False
PSComputerName :

Caption        :
Description    : Provides ultimate performance on higher end PCs.
ElementName    : Ultimate Performance
InstanceID     : Microsoft:PowerPlan\{1234-guid-abc-4}
IsActive       : False
PSComputerName :

Upvotes: 2

Views: 5154

Answers (1)

satoukum
satoukum

Reputation: 1258

Solution was to rebuild the WMI repository.

At first I followed instructions online to rebuild from MOF files, but those didn't work, so I made a backup of the repository and then copied over a working repository from another machine.

Location: C:\Windows\System32\wbem\repository

Upvotes: 4

Related Questions