ConfigMgr Client Boundary Membership Query

One thing I dislike about ConfigMgr is that there isn’t a SQL view I can easily reference to determine what boundary or boundaries my clients are part of. IP subnet and AD site boundaries are easy to do, but what about those IP range based boundaries.

With the help of our Microsoft PFE, I now have a solution. He sent me a query that used two views/tables I was not aware of and I was able to modify his query and use it to build out a custom table.

In order to determine if a system falls within a boundary, you need to takes its IP address and see if it falls within the boundary’s range. This is done using numerical value of the IP address and the numerical values of the start and stop IP address of the range. Luckily, this data can be found in the ConfigMgr database so you do not have to manually calculate these values. System_IP_Address_ARR stores the IP address numerical value and BoundaryEx stores the numerical value of the start and stop IP addresses of the IP range.

Again, with the help of our Microsoft PFE, I was able to create a query the lists out all the ResourceIDs and their associated BoundaryIDs regardless of type of boundary. I have taken this query, changed it to dump into a table and then used a schedule job to refresh the data on a daily basis.

SQL file can be grabbed from https://github.com/NecroMonkey/vault/blob/master/SQL/client_boundary_membership.sql

SELECT DISTINCT
sysr.ResourceID,
ipr.BoundaryID
FROM v_R_System sysr
JOIN System_IP_Address_ARR ip ON ip.ItemKey = sysr.ResourceID AND ip.NumericIPAddressValue <> 0
JOIN v_RA_System_IPSubnets sub ON sub.ResourceID = sysr.ResourceID
LEFT JOIN v_RA_System_IPv6Prefixes v6 ON v6.ResourceID = sysr.ResourceID
JOIN BoundaryEx AS ipr ON
-- Check BoundaryType 3 (IPRANGE)
(ipr.BoundaryType = 3 AND ip.NumericIPAddressValue BETWEEN ipr.NumericValueLow AND ipr.NumericValueHigh)
-- Check BoundaryType 1 (ADSITE)
OR (ipr.BoundaryType = 1 AND ipr.Value = sysr.AD_Site_Name0)
-- Check BoundaryType 0 (IPSUBNET)
OR (ipr.BoundaryType = 0 AND ipr.Value = sub.IP_Subnets0)
-- Check BoundaryType 2 (IPv6)
OR (ipr.BoundaryType = 2 AND ipr.Value = v6.IPv6_Prefixes0)
ORDER BY sysr.ResourceID