March 15, 2009
During Deployments (also in other situations but this Blog is more about Deployments) you sometimes need to gather some information about the existing SMS/SCCM Infrastructure. Mainly things like the SiteCode for a specific computer or even more important the assignedSiteCode (From the assigned Primary Site) and the siteServers responsible for these sites.
How do we get this information? The easiest way is probably hardcoding this information somewhere. We could store it in the cs.ini if using MDT or directly in the scripts doing the SMS/SCCM Parts of our deployment. But hardcoding is never a really good solution if it comes to dynamic and/or large environments. A second way comes with SMS/SCCM out-of-the-box. The Server Locator Point (SLP). A Role you can add to any of your SCCM Server and which will be able to return a lot of information about your SCCM Infrastructure. But you need to know the SLP-Server. And it is not necessarily installed in every infrastructure. Especially if you extended the Active Directory Schema and published the site information it's not required.
So this Post is about how to get this information from our Active Directory.
If you extend the Active Directory Schema for SCCM (and SMS as wel) it will create a new container below the System container called "System Management". I suggest you download the ADExplorer from SysInternals to follow me through this. It contains a couple of different objects. Let's start with the already mentioned SLP. The SLP object in AD has the objectClass "mSSMSServerLocatorPoint". So if you would like to know all configured SLPs in your SCCM Environment search for all objects within the "System Management" Container with an objectClass of "mSSMSServerLocatorPoint". The name of the SLP Server is contained in the attribute "mSSMSMPName".
Next important thing we need to know is the siteCode for a Client (and the AssignedSiteCode of course). Now it get's a bit more complicated. In this case a specific sitecode is defined by a range of IP Addresses. So we query the "System Management" Container for objects with an objectClass of "mSSMSRoamingBoundaryRange". The IP Range for this Object is defined by the first and the last IP Address of the range. These values are stored in the Attributes "mSSMSRangedIPLow" and "mSSMSRangedIPHigh". The IP Addresses are stored in decimal, not dotted decimal notation so we need to convert our IP Address first. Please have a look on by Blog Post Get Active Directory Site for IP Address. It explains how you can convert an IP Address from dotted decimal to decimal. Now we just need to loop through all found objects and check if a given IP Address is between those two values. If so, the client belongs to this site. The information we want is now stored in the "mSSMSSiteCode" and "mSSMSAssignmentSiteCode" attributes of the object.
OK, we now can get the siteCode/AssignedSiteCode but we still need to know the SiteServer for a given SiteCode. To get this information we query again the "System Management" Container for all objects with an objectClass of "mSSMSManagementPoint", the Attribute "mSSMSDefaultMP = TRUE" and "mSSMSSiteCode = MySiteCode". If we found an object (and we should otherwise the boundaries are a bit messed up or not correctly published to AD) the SiteServer name can be found in the attribute "mSSMSMPName".
For all which don't want to mess around searching this by themselves, just download the webservice from my post A Webservice for OSD and MDT Deployments. It contains a couple of functions which will do exactly what I described here.
Comments