I have a script that simply connects to the registry of a remote computer via WMI and Powershell:
$Server = server1
$HKLM = [UInt32] "0x80000002"
$WMI_Reg = [WMIClass] "\\server1\root\default:StdRegProv"
For the majority of our 300 servers this is fine and I can make subsequent queries on the registry. However, for a select few, I get this error:
Cannot convert value "\server1\root\default:stdregprov" to type "System.Management.ManagementClass". Error: "not found"
These are all 2008 R2 servers. Originally, there were issues with invalid WMI providers and I had to recompile cimWin32.mof prior to this error.
Any ideas on what I can do next?
Thanks
These errors are usually caused by missing WMI classes. The solution for this kind of error usually involves couple of steps.
The solutions could be found under this link: https://blogs.technet.microsoft.com/askperf/2014/08/11/wmi-missing-or-failing-wmi-providers-or-invalid-wmi-class/
Important: as per Microsoft, please don't rebuild mof files as the first step:
"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."
Cannot convert value "\server1\root\default:stdregprov" to type "System.Management.ManagementClass". Error: "not found"
This error is because it did not find the key that you are looking for. That's a basic case when key does not exist. Can you check if registry key exists?
As per the information provide, there is no issue with WMI
here.
You can always use try and catch block to throw exception and move forward.
User contributions licensed under CC BY-SA 3.0