How to List Distribution Points for a Site
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
The following example shows how to assign a distribution point to a package by using the SMS_DistributionPoint Server WMI Class class and class properties in System Center 2012 R2 Configuration Manager.
You only need to assign a distribution point to a package if the package contains source files. The package is not advertised until the program source files have been propagated to a distribution point share. You can use the default distribution point share, or you can specify a share to use. You can also specify more than one distribution point to use to distribute your package source files, although the following example does not demonstrate that.
Note |
|---|
To identify branch distribution points, check the IsPeerDP property of the specific SMS_DistributionPoint class instance. If the IsPeerDP property is true, then the distribution point is a branch distribution point. |
To list distribution points for a site
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Run a query, which populates a variable with a collection of distribution point objects.
Enumerate through the collection of and list the distribution points returned by the query.
Example
The following example method lists distribution points for a site.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub ListDistributionPointsForSite(connection, siteCode)
' This query selects all distribution points for a site based on the provided site code.
Query = "SELECT * FROM SMS_SystemResourceList WHERE RoleName='SMS Distribution Point' AND SiteCode='" & siteCode & "'"
' Run query, which populates listOfResources with a collection of objects.
Set ListOfResources = connection.ExecQuery(query, , wbemFlagForwardOnly Or wbemFlagReturnImmediately)
' Output header for list of distribution points.
Wscript.Echo "List of distribution points for site: " & siteCode
Wscript.Echo "--------------------------------------------"
' Enumerate through the collection of objects returned by the query.
For Each resource In listOfResources
' Output the server name for each distribution point.
Wscript.Echo resource.ServerName
Next
End Sub
public void ListDistributionPointsForSite(WqlConnectionManager connection, string siteCode) { try { // This query selects all distribution points for a site based on the provided site code. string query = "SELECT * FROM SMS_SystemResourceList WHERE RoleName='SMS Distribution Point' AND SiteCode='" + siteCode + "'"; // Run query, which populates 'listOfResources' with a collection of objects. IResultObject listOfResources = connection.QueryProcessor.ExecuteQuery(query); // Output header for list of distribution points. Console.WriteLine("List of distribution points for site: " + siteCode); Console.WriteLine("--------------------------------------------"); // Enumerate through the collection of objects returned by the query. foreach (IResultObject resource in listOfResources) { // Output the server name for each distribution point. Console.WriteLine(resource["ServerName"].StringValue); } } catch (SmsException ex) { Console.WriteLine("Failed to list distribution points. Error: " + ex.Message); throw; } }
Compiling the Code
The C# example requires:
System
System.Collections.Generic
System.ComponentModel
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
.NET Framework Security
For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.
Configuration Manager Software Distribution
Distribution Points
About the Configuration Manager Site Control File
How to Read and Write to the Configuration Manager Site Control File by Using Managed Code
How to Read and Write to the Configuration Manager Site Control File by Using WMI
SMS_SCI_Component Server WMI Class
SMS_DistributionPoint Server WMI Class

The example method has the following parameters:
Parameter
Type
Description
connection
swebemServices
Managed: WqlConnectionManager
VBScript: SWbemServices
A valid connection to the SMS Provider.
siteCode
Managed: String
VBScript: String
The site code for the site that supports the distribution points.