Partilhar via


How to Set the PXE Service Point Response for a Specific Network Interface

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

In Microsoft System Center Configuration Manager 2007, you set the operating system deployment to respond to a specific set of network addresses by adding the required media access control (MAC) addresses to the BindExcept embedded property list. You must also set the BindPolicy embedded property to 1. This specifies that PXE requests are accepted on specified network address only. For more information about setting BindPolicy, see How to Set the PXE Service Point Response to Network Interfaces.

To set the response for a specific network interface

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

  2. Make a connection to the PXE service point resources section of the site control file.

  3. Get the BindExcept embedded property list.

  4. Add the MAC addresses to the BindExcept embedded property list.

  5. Commit the changes to the site control file.

Example

The following example method adds a supplied MAC address to the list of MAC address that are responded to.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Sub SetNetworkInterface (connection, context,server, siteCode, macAddress)

    Dim InParams
    Dim found
      
      Set InParams = connection.Get("SMS_SiteControlFile").Methods_("RefreshSCF").InParameters.SpawnInstance_
InParams.SiteCode = siteCode
connection.ExecMethod "SMS_SiteControlFile", "RefreshSCF", InParams, , Context

        
    Query = "SELECT * FROM SMS_SCI_SysResUse " & _
            "WHERE RoleName = 'SMS PXE Service Point' " & _
            "AND SiteCode = '" & siteCode & "'"
    
    found = false
    
    Set SCIComponentSet = connection.ExecQuery(Query, , , context)
                       
    ' Only one instance is returned from the query.
    For Each SCIComponent In SCIComponentSet
         
        ' Add the new MAC address.
        For Each vProperty in SCIComponent.PropLists
            if   vProperty.PropertyListName = "BindExcept" Then

                Dim  macAddresses 
                Dim i
                
                found = true
                
                ' Resize the array to accommodate the new MAC address.
                ReDim  macAddresses(UBound (vProperty.Values)+1)
                 
                 for i  = 0 to UBound(vProperty.Values) 
                    macAddresses(i) = vProperty.Values(i)
                 Next
             
                macAddresses(ubound (macAddresses))= macAddress
                vProperty.Values = macAddresses
            End If
        Next
        
        ' Did not find BindExcept, so create it.
        If found = False Then
            Set embeddedPropertyList = goWMIConnection.Get("SMS_EmbeddedPropertyList").Spawninstance_()
            embeddedPropertyList.PropertyListName = "BindExcept"
            embeddedPropertyList.Values = Array(macAddress)
            
            SCIComponent.Proplists = Array(embeddedPropertyList)
        End If     


             ' Update the component in your copy of the site control file. Get the path
             ' to the updated object, which could be used later to retrieve the instance.
             Set SCICompPath = SCIComponent.Put_( , context)
    Next
                          
    ' Commit the change to the actual site control file.
    Set InParams = connection.Get("SMS_SiteControlFile").Methods_("CommitSCF").InParameters.SpawnInstance_
    InParams.SiteCode = siteCode
   connection.ExecMethod "SMS_SiteControlFile", "CommitSCF", InParams, , context
      
End Sub
public void SetNetworkInterface(
    WqlConnectionManager connection, 
    string server, 
    string siteCode, 
    string macAddress)
{
    try
    {
        // Get PXE properties.
        IResultObject ro = connection.GetInstance("SMS_SCI_SysResUse.FileType=2,ItemName='[\"Display=\\\\" 
            + server + "\\\"]MSWNET:[\"SMS_SITE=" + 
            siteCode + "\"]\\\\" + 
            server + "\\,SMS PXE Service Point',ItemType='System Resource Usage',SiteCode='" + 
            siteCode + "'");

        Dictionary<string, IResultObject> embeddedPropertyLists = ro.EmbeddedPropertyLists;

        string[] macAddresses = embeddedPropertyLists["BindExcept"]["Values"].StringArrayValue; // mac addresses

        List<string> addressList = new List<string>(); // Convert to list.
        foreach (string mac in macAddresses)
        {
            addressList.Add(mac);
        }

        addressList.Add(macAddress);  // Add the new mac address.
        embeddedPropertyLists["BindExcept"]["Values"].StringArrayValue = addressList.ToArray();
        ro.EmbeddedPropertyLists = embeddedPropertyLists;
        
        // Commit the changes.
        ro.Put();
    }
    catch (SmsException e)
    {
        Console.WriteLine("Failed to set PXE response for a specific network: " + e.Message);
        throw;
    }
}     

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

connection (VBScript)

  • VBScript: SWbemContext

A valid context object. For more information, see How to Add a Configuration Manager Context Qualifier by Using WMI.

server

  • Managed: String

  • VBScript: String

The Configuration Manager server.

siteCode

  • Managed: String

  • VBScript: String

The Configuration Manager site code.

macAddress

  • Managed: String

  • VBScript: String

The MAC address to be added in the following format:

00:11:22:33:44:55

Compiling the Code

The C# example has the following compilation requirements:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

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

Security

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

See Also

Concepts

About Operating System Deployment Site Role Configuration
Configuration Manager Operating System Deployment
Configuration Manager Programming Fundamentals
Configuration Manager Site Control File
Operating System Deployment Site Role Configuration
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