对 Win32_PowerPlan 的 Powershell 调用显示无效 class 错误
Powershell call to Win32_PowerPlan showing invalid class error
如何让这个 Powershell 命令起作用?这是否意味着我的非工作机器上的某些东西已损坏?要解决哪些步骤?
non-working/broken 机器上的命令:
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 :
解决方案是重建 WMI 存储库。
起初我按照网上的说明从 MOF 文件重建,但这些都不起作用,所以我备份了存储库,然后从另一台机器上复制了一个工作存储库。
地点:C:\Windows\System32\wbem\respository
如何让这个 Powershell 命令起作用?这是否意味着我的非工作机器上的某些东西已损坏?要解决哪些步骤?
non-working/broken 机器上的命令:
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 :
解决方案是重建 WMI 存储库。
起初我按照网上的说明从 MOF 文件重建,但这些都不起作用,所以我备份了存储库,然后从另一台机器上复制了一个工作存储库。
地点:C:\Windows\System32\wbem\respository