Contact Info

Crumbtrail

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

Win32 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 Win32 WMI class can be used in ActiveXperts Network Monitor to monitor your servers.


Sample Code

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

for obj in objWMI:
	if obj.Caption != None:
		print("Caption:" + str(obj.Caption))
	if obj.Description != None:
		print("Description:" + str(obj.Description))
	if obj.Domain != None:
		print("Domain:" + str(obj.Domain))
	if obj.InstallDate != None:
		print("InstallDate:" + str(obj.InstallDate))
	if obj.LocalAccount != None:
		print("LocalAccount:" + str(obj.LocalAccount))
	if obj.Name != None:
		print("Name:" + str(obj.Name))
	if obj.SID != None:
		print("SID:" + str(obj.SID))
	if obj.SIDType != None:
		print("SIDType:" + str(obj.SIDType))
	if obj.Status != None:
		print("Status:" + str(obj.Status))
	print("")
	print("########")
	print("")