2016-09-23 51 views
1

访问远程注册表时我有一个简单的连接到通过WMI和PowerShell远程计算机的注册表脚本:PowerShell的:通过WMI

$Server = server1 
$HKLM = [UInt32] "0x80000002" 
$WMI_Reg = [WMIClass] "\\server1\root\default:StdRegProv" 

为广大300台的服务器,这是好的,我可以做后续查询注册表。但是,对于少数几个人,我收到此错误:

Cannot convert value "\server1\root\default:stdregprov" to type "System.Management.ManagementClass". Error: "not found"

这些都是2008 R2服务器。最初,存在无效WMI提供程序的问题,我必须在出现此错误之前重新编译cimWin32.mof。

关于接下来我能做什么的任何想法?

谢谢

回答

0

这些错误通常是由缺少WMI类引起的。这种错误的解决方案通常涉及几个步骤。 https://blogs.technet.microsoft.com/askperf/2014/08/11/wmi-missing-or-failing-wmi-providers-or-invalid-wmi-class/

重要:按照微软,请不要重建MOF文件作为第一步:

"Rebuilding the repository or recompiling all of the .mof files as a first action when other steps should be taken first can cause damage to the system and/or to installed applications."

0

无法转换值“\ server1的\

的解决方案,可以此链接下找到root \ default:stdregprov“键入”System.Management.ManagementClass“。 错误:“未找到”

此错误是因为它没有找到您正在寻找的密钥。这是钥匙不存在的基本情况。你可以检查注册表项是否存在?

根据提供的信息,这里没有WMI的问题。

您可以随时使用try和catch块来抛出异常并向前移动。