powershell - 对 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 :
解决方案
解决方案是重建 WMI 存储库。
起初,我按照在线说明从 MOF 文件重建,但这些都不起作用,所以我对存储库进行了备份,然后从另一台机器复制到工作存储库。
地点:C:\Windows\System32\wbem\respository
推荐阅读
- python - 将两个变量放在这样的 if 语句中是什么意思:variable[variable2]?
- python - 如何在条形图上绘制一条垂直线,其日期时间标签只有谨慎的 x 轴刻度位置?
- assembly - 如何在asm中的函数序言之前中断
- azure - Terraform AZ CLI 本地执行命令限制
- javascript - 如何根据单元格值将 Google Sheet 中的数据显示到 Google Web App?
- javascript - 使用 PptxGenJS 向 PowerPoint 幻灯片添加过渡
- python - 在 KeyCloak 中绕过“执行以下操作”?
- facebook - 如何为 Instagram 基本显示 API 实现 Instagram 或 Facebook 登录按钮的继续?
- c++ - 错误:非静态引用成员 - 不能使用默认赋值运算符
- linux - 在 julia 中设置 pandas 时出错:找不到键“_IXIndexer”