Contact Info

Crumbtrail

ActiveXperts.com » Administration » Scripts » WMI » python sample

CIM python sample code

The foundations for Manageability in Windows is Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself. The CIM WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

from win32com.client import GetObject
objWMI = GetObject('winmgmts:').InstancesOf('CIM_Action')

for obj in objWMI:
	if obj.ActionID != None:
		print("ActionID:" + str(obj.ActionID))
	if obj.AppID != None:
		print("AppID:" + str(obj.AppID))
	if obj.Argument != None:
		print("Argument:" + str(obj.Argument))
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.CLSID != None:
		print("CLSID:" + str(obj.CLSID))
	if obj.Context != None:
		print("Context:" + str(obj.Context))
	if obj.DefInprocHandler != None:
		print("DefInprocHandler:" + str(obj.DefInprocHandler))
	if obj.Description != None:
		print("Description:" + str(obj.Description))
	if obj.Direction != None:
		print("Direction:" + str(obj.Direction))
	if obj.FileTypeMask != None:
		print("FileTypeMask:" + str(obj.FileTypeMask))
	if obj.Insertable != None:
		print("Insertable:" + str(obj.Insertable))
	if obj.Name != None:
		print("Name:" + str(obj.Name))
	if obj.ProgID != None:
		print("ProgID:" + str(obj.ProgID))
	if obj.RemoteName != None:
		print("RemoteName:" + str(obj.RemoteName))
	if obj.SoftwareElementID != None:
		print("SoftwareElementID:" + str(obj.SoftwareElementID))
	if obj.SoftwareElementState != None:
		print("SoftwareElementState:" + str(obj.SoftwareElementState))
	if obj.TargetOperatingSystem != None:
		print("TargetOperatingSystem:" + str(obj.TargetOperatingSystem))
	if obj.Version != None:
		print("Version:" + str(obj.Version))
	if obj.VIProgID != None:
		print("VIProgID:" + str(obj.VIProgID))
	print("")
	print("########")
	print("")