다음을 통해 공유


How to List Distribution Points for a Site

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

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 Microsoft System Center Configuration Manager 2007.

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

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Run a query, which populates a variable with a collection of distribution point objects.

  3. 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;
    }
}

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.

Compiling the Code

The C# example requires:

Namespaces

System

System.Collections.Generic

System.ComponentModel

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also

Reference

SMS_DistributionPoint Server WMI Class

Concepts

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