/
show_filtertoconsumerbindings.py
40 lines (30 loc) · 1.3 KB
/
show_filtertoconsumerbindings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import logging
from cim import CIM
from cim.objects import Namespace
def main(type_, path):
if type_ not in ("xp", "win7"):
raise RuntimeError("Invalid mapping type: {:s}".format(type_))
c = CIM(type_, path)
with Namespace(c, "root\\subscription") as ns:
for binding in ns.class_("__filtertoconsumerbinding").instances:
print("binding: ", binding)
filterref = binding.properties["Filter"].value
consumerref = binding.properties["Consumer"].value
filter = ns.get(ns.parse_object_path(filterref))
consumer = ns.get(ns.parse_object_path(consumerref))
print(" filter: ", filter)
try:
print(" language: ", filter.properties["QueryLanguage"].value)
print(" query: ", filter.properties["Query"].value)
except IndexError:
print(" not found.")
print(" consumer: ", consumer)
try:
if "CommandLineTemplate" in consumer.properties:
print(" payload: ", consumer.properties["CommandLineTemplate"].value)
except IndexError:
print(" not found.")
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
import sys
main(*sys.argv[1:])