A question that comes up fairly often is how to programmatically determine which objects are related to another object. An example of this is: "How do I get the members of a group?"
Here is a quick code sample that shows how to do this:
void Main(string args)
EnterpriseManagementGroup emg = new
// Note: You'll need to get a GUID that makes sense in your deployment to put in here. You can get this from the BaseManagedEntityTable.
// Make sure for this example code to work that you choose an object which contains other objects like a group or a Windows computer.
Guid guidObjectID = new
ManagementPack mpSystem = emg.ManagementPacks.GetManagementPack(SystemManagementPack.System);
ManagementPackRelationship relContainment = mpSystem.GetRelationship("System.Containment");
TraversalDepth tdRecursive = TraversalDepth.Recursive;
IList<EnterpriseManagementObject> listContainedObjects = emg.EntityObjects.GetRelatedObjects<EnterpriseManagementObject>(guidObjectID, relContainment, tdRecursive, ObjectQueryOptions.Default);
foreach (EnterpriseManagementObject emo in listContainedObjects)
The key to this is the GetRelatedObjects() method. There are 10 overloads for this method so there are lots of different ways to query. You can filter by relationship type as I did above or by class. You can even use property level criteria.
Example command line application can be found here:
Where can I found the SCSM SDK ?
@SCSM SDK - you can find the SDK documentation here:
The SDK binaries themselves ship with the product and are installed on the SCSM Management Server in the folder:
C:\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries
How about "How do I get the groups where the user is a member?"