Powershell 无效类错误

问题描述 投票:0回答:1

尝试运行powershell命令

Get-WmiObject win32_physicalmemory
PS C:\> Get-WmiObject win32_physicalmemory
Get-WmiObject : Invalid class "win32_physicalmemory"
At line:1 char:1
+ Get-WmiObject win32_physicalmemory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

然后我读到 wmi 数据库可能已损坏,但是当我运行时

PS C:\> winmgmt /verifyrepository
WMI repository is consistent

还值得重建wmi数据库吗?

powershell
1个回答
0
投票

在重建 WMI 存储库之前,请尝试重新编译与 Win32_PhysicalMemory 类相关的 .mof 文件。这可以解决丢失或未注册 WMI 类的问题。

cd C:\Windows\System32\wbem
mofcomp CIMWin32.mof

这将重新编译

CIMWin32.mof
文件,其中包括 Win32_PhysicalMemory 类的定义。

© www.soinside.com 2019 - 2024. All rights reserved.