首页 > 解决方案 > 对 Win32_PowerPlan 的 Powershell 调用显示无效类错误

问题描述

如何让这个 Powershell 命令正常工作?这是否意味着我的非工作机器上的某些东西已损坏?有哪些步骤可以解决?

非工作/损坏机器上的命令:

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

工作机器上的命令:

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 :

标签: powershellwinapi

解决方案


解决方案是重建 WMI 存储库。

起初,我按照在线说明从 MOF 文件重建,但这些都不起作用,所以我对存储库进行了备份,然后从另一台机器复制到工作存储库。

地点:C:\Windows\System32\wbem\respository


推荐阅读