Contact Info

Crumbtrail » Administration » Scripts » WMI Performance Counters » VBScript

PolicyRule - WMI sample in VBScript

The foundations for Manageability in Windows 2019/2012/2008/ and Windows 10/8/7/Vista/XP are 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.

On this site, you can find many WMI samples.

The PolicyRule WMI class can be used in ActiveXperts Network Monitor to monitor your servers.



Set objWMIService = GetObject("winmgmts:\\.\root\StandardCimv2")

Set colItems = objWMIService.ExecQuery("Select * From CIM_PolicyRule")

For Each objItem in colItems
	WScript.Echo "Action:" & objItem.Action
	WScript.Echo "Caption:" & objItem.Caption
	WScript.Echo "CommonName:" & objItem.CommonName
	WScript.Echo "ConditionListType:" & objItem.ConditionListType
	WScript.Echo "CreationClassName:" & objItem.CreationClassName
	WScript.Echo "Description:" & objItem.Description
	WScript.Echo "Direction:" & objItem.Direction
	WScript.Echo "DisplayGroup:" & objItem.DisplayGroup
	WScript.Echo "DisplayName:" & objItem.DisplayName
	WScript.Echo "EdgeTraversalPolicy:" & objItem.EdgeTraversalPolicy
	WScript.Echo "ElementName:" & objItem.ElementName
	WScript.Echo "Enabled:" & objItem.Enabled
	WScript.Echo "EnforcementStatus:" & Join(objItem.EnforcementStatus)
	WScript.Echo "ExecutionStrategy:" & objItem.ExecutionStrategy
	WScript.Echo "InstanceID:" & objItem.InstanceID
	WScript.Echo "LocalOnlyMapping:" & objItem.LocalOnlyMapping
	WScript.Echo "LooseSourceMapping:" & objItem.LooseSourceMapping
	WScript.Echo "Mandatory:" & objItem.Mandatory
	WScript.Echo "Owner:" & objItem.Owner
	WScript.Echo "Platforms:" & Join(objItem.Platforms)
	WScript.Echo "PolicyDecisionStrategy:" & objItem.PolicyDecisionStrategy
	WScript.Echo "PolicyKeywords:" & Join(objItem.PolicyKeywords)
	WScript.Echo "PolicyRoles:" & Join(objItem.PolicyRoles)
	WScript.Echo "PolicyRuleName:" & objItem.PolicyRuleName
	WScript.Echo "PolicyStoreSource:" & objItem.PolicyStoreSource
	WScript.Echo "PolicyStoreSourceType:" & objItem.PolicyStoreSourceType
	WScript.Echo "PrimaryStatus:" & objItem.PrimaryStatus
	WScript.Echo "Priority:" & objItem.Priority
	WScript.Echo "Profiles:" & objItem.Profiles
	WScript.Echo "RuleGroup:" & objItem.RuleGroup
	WScript.Echo "RuleUsage:" & objItem.RuleUsage
	WScript.Echo "SequencedActions:" & objItem.SequencedActions
	WScript.Echo "Status:" & objItem.Status
	WScript.Echo "StatusCode:" & objItem.StatusCode
	WScript.Echo "SystemCreationClassName:" & objItem.SystemCreationClassName
	WScript.Echo "SystemName:" & objItem.SystemName
	WScript.Echo ""
	WScript.Echo "########"
	WScript.Echo ""