I have a problem with the python3 pyad module. I'd like to query my active directory environment for all PCs with some Information and if they are enabled or not.
This is the code:
q = pyad.adquery.ADQuery()
q.execute_query(
attributes = ["CN", "OperatingSystem", "OperatingSystemVersion", "Description", "Enabled"],
where_clause = "objectClass = 'Computer'",
base_dn = "OU=Client,OU=####,OU=########,DC=###############,DC=########,DC=local"
)
ad_result = []
for row in q.get_results():
ad_result.append(row)
print(row)
This is what I am getting back:
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
{'Enabled': None, 'Description': None, 'OperatingSystemVersion': '10.0 (17763)', 'OperatingSystem': 'Windows 10 Pro', 'CN': '<PC NAME>'}
So my problem is that instead of getting back the "Enabled" Status as True or False, I only get None. It works fine when I query via Powershell, but I'd really like to use python. I don't want to bodge some Powershell csv export into my script. If anyone has any idea I'd appreciate an answer, thank you.