Have you ever wanted to check if AD Integration is enabled for an Agent using a SQL query? Today I wanted to do that and I created the next SQL Query. You may find it usefull.

/*
Find all Agent where AD Integration is configured
Run on OperationsManager Database
Initial query: Daniele Muscetta
*/
SELECT bme.DisplayName, mths.ActiveDirectoryManaged
FROM MT_HealthService mths
INNER JOIN BaseManagedEntity bme on bme.BaseManagedEntityId = mths.BaseManagedEntityId
WHERE ActiveDirectoryManaged = 1
ORDER BY DisplayName

/*
Find all Agent where AD Integration is not configured
Run on OperationsManager Database
Initial query: Daniele Muscetta
*/
SELECT bme.DisplayName, mths.ActiveDirectoryManaged
FROM MT_HealthService mths
INNER JOIN BaseManagedEntity bme on bme.BaseManagedEntityId = mths.BaseManagedEntityId
WHERE ActiveDirectoryManaged = 0
ORDER BY DisplayName