如何为特定网络接口设置 PXE 服务点响应

在 Configuration Manager 中,通过将所需的媒体访问控制 (MAC) 地址添加到嵌入式属性列表,设置作系统部署以BindExcept响应一组特定的网络地址。 还必须将 BindPolicy 嵌入属性设置为 1。 这指定仅在指定的网络地址上接受 PXE 请求。 有关设置 BindPolicy的详细信息,请参阅 如何将 PXE 服务点响应设置为所有网络接口

设置特定网络接口的响应

  1. 设置与 SMS 提供程序的连接。 有关详细信息,请参阅 SMS 提供程序基础知识

  2. 与站点控制文件的 PXE 服务点资源部分建立连接。

  3. 获取 BindExcept 嵌入的属性列表。

  4. 将 MAC 地址添加到 BindExcept 嵌入式属性列表。

  5. 提交对站点控制文件的更改。

示例

以下示例方法将提供的 MAC 地址添加到响应的 MAC 地址列表中。

有关调用示例代码的信息,请参阅调用Configuration Manager代码片段

public void SetNetworkInterface(WqlConnectionManager connection,                                string siteCode,                                string serverName,                                string macAddress){    try    {        //Connect to distribution point instance.                        IResultObject siteRole = connection.GetInstance("SMS_SCI_SysResUse.FileType=2,ItemName=\"[\\\"Display=\\\\\\\\" + serverName + "\\\\\\\"]MSWNET:[\\\"SMS_SITE=" + siteCode + "\\\"]\\\\\\\\" + serverName + "\\\\,SMS Distribution Point\",ItemType=\"System Resource Usage\",SiteCode=" + "\"" + siteCode + "\"");        // Create temporary copy of the embedded properties.        Dictionary<string, IResultObject> embeddedPropertyLists = siteRole.EmbeddedPropertyLists;        // Get current mac addresses.        string[] macAddresses = embeddedPropertyLists["BindExcept"]["Values"].StringArrayValue;        //Convert to list.        List<string> addressList = new List<string>();        foreach (string address in macAddresses)        {            addressList.Add(address);        }        // Add the new mac address to the list.        addressList.Add(macAddress);        // Add the new mac address to the list.        embeddedPropertyLists["BindExcept"]["Values"].StringArrayValue = addressList.ToArray();        siteRole.EmbeddedPropertyLists = embeddedPropertyLists;        // Save the settings.         siteRole.Put();    }    catch (SmsException ex)    {        Console.WriteLine();        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);    }}

示例方法具有以下参数:

参数 类型 说明
connection -管理: WqlConnectionManager 与 SMS 提供程序的有效连接。
serverName -管理: String Configuration Manager服务器。
siteCode -管理: String Configuration Manager站点代码。
macAddress -管理: String 要按以下格式添加的 MAC 地址:

00:11:22:33:44:55

编译代码

C# 示例具有以下编译要求:

命名空间

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

可靠编程

有关错误处理的详细信息,请参阅关于Configuration Manager错误

.NET Framework 安全性

有关保护Configuration Manager应用程序的详细信息,请参阅Configuration Manager基于角色的管理

另请参阅

关于 OS 部署站点角色配置如何使用托管代码读取和写入Configuration Manager站点控制文件 如何使用 WMI 读取和写入Configuration Manager站点控制文件