如何启用 PXE 服务点角色

在 Configuration Manager 中,通过获取特定分发点的实例并将值设置为 IsPXE1启用 PXE 服务点角色。

启用 PXE 服务点角色

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

  2. 获取特定分发点的实例。

  3. IsPXE 嵌入属性设置为 1

  4. 保存分发点实例。

示例

以下示例方法启用 PXE 服务点。

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

public void EnablePXE(WqlConnectionManager connection,                      string siteCode,                      string serverName){    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> embeddedProperties = siteRole.EmbeddedProperties;        // Enumerate through the embedded properties and makes changes as needed.        foreach (KeyValuePair<string, IResultObject> kvp in siteRole.EmbeddedProperties)        {            // Setting: IsPXE            if (kvp.Value.PropertyList["PropertyName"] == "IsPXE")            {                // Get current property value.                Console.WriteLine();                Console.WriteLine("Property: {0}", kvp.Value.PropertyList["PropertyName"]);                Console.WriteLine("Current value: {0} (0 not enabled, 1 enabled)", kvp.Value.PropertyList["Value"]);                // Change value to enable PXE (1 enabled, 0 not enabled).                 embeddedProperties["IsPXE"]["Value"].StringValue = "1";                Console.WriteLine("Setting the {0} value to {1}.", kvp.Value.PropertyList["PropertyName"], "1");            }        }        // Store the settings that have changed.        siteRole.EmbeddedProperties = embeddedProperties;        // Save the settings.         siteRole.Put();    }    catch (SmsException ex)    {        Console.WriteLine();        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);    }}   

示例方法具有以下参数:

参数 类型 说明
connection 管理: WqlConnectionManager 与 SMS 提供程序的有效连接。
siteCode 管理: String Configuration Manager站点代码。
serverName 管理: String 服务器名称。 例如,"SERVER1.DOMAIN1.COM"

编译代码

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基于角色的管理

另请参阅

SMS_SCI_SysResUse服务器 WMI 类
类SMS_NAL_Methods中的 PackNALPath 方法
关于 OS 部署站点角色配置如何设置 PXE 服务点的响应延迟
如何将 PXE 服务点响应设置为所有网络接口
如何将 PXE 服务点响应设置为 PXE 请求
如何使用托管代码读取和写入Configuration Manager站点控制文件
如何使用 WMI 读取和写入Configuration Manager站点控制文件