Answer the question
In order to leave comments, you need to log in
Why does it give an error when accessing through WMI?
I'm trying to implement hyper-v based VM management via Python.
Why doesn't it see the Msvm_ComputerSystem() class ?
Based on this article , I make a request:
connection = wmi.connect_server(server="ip_adress", namespace=r"root\cimv2", user=r"name", password=r"pass")
c = wmi.WMI(wmi=connection)
c.Msvm_ComputerSystem()
Traceback (most recent call last):
File "C:\Users\_____________\venv\lib\site-packages\wmi.py", line 1209, in __getattr__
return self._cached_classes(attribute)
File "C:\Users\____________\venv\lib\site-packages\wmi.py", line 1220, in _cached_classes
self._classes_map[class_name] = _wmi_class(self, self._namespace.Get(class_name))
File "<COMObject <unknown>>", line 3, in Get
File "C:\Users\_______________\venv\lib\site-packages\win32com\client\dynamic.py", line 287, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
pywintypes.com_error: (-2147352567, 'Error.', (0, 'SWbemServicesEx', 'Not found ', None, 0, -2147217406), None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/_______________/test.py", line 12, in <module>
c.Msvm_ComputerSystem()
File "C:\Users\______________________\venv\lib\site-packages\wmi.py", line 1211, in __getattr__
return getattr(self._namespace, attribute)
File "C:\Users\___________________\venv\lib\site-packages\win32com\client\dynamic.py", line 527, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: <unknown>.Msvm_ComputerSystem
connection = wmi.connect_server(server="ip_adress", namespace=r"root\cimv2", user=r"name", password=r"pass")
c = wmi.WMI(wmi=connection)
for os in c.Win32_OperatingSystem():
print(os.Caption)
Microsoft Windows Server 2012 R2 Datacenter
Process finished with exit code 0
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question