如何将 PXE 服务点响应设置为 PXE 请求
在 Configuration Manager中,通过设置 IsActive 嵌入式属性,将分发点响应设置为传入的 PXE 请求。
IsActive 具有以下可能值。
值 | 说明 |
---|---|
0 | 分发点不响应 PXE 请求。 |
1 | 分发点服务点响应请求。 |
设置 PXE 请求的分发点响应
设置与 SMS 提供程序的连接。 有关详细信息,请参阅 SMS 提供程序基础知识。
与启用了 PXE 的分发点实例建立连接。
获取嵌入的属性。
更新 IsActive 嵌入式属性。
提交对站点控制文件的更改。
示例
以下示例方法根据提供的 String
值 () allowResponse
设置 PXE 请求的响应。
有关调用示例代码的信息,请参阅调用Configuration Manager代码片段。
public void SetAllowResponse(WqlConnectionManager connection, string siteCode, string serverName, string allowResponse){ 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: IsActive if (kvp.Value.PropertyList["PropertyName"] == "IsActive") { // Get current property value. Console.WriteLine(); Console.WriteLine("Property: {0}", kvp.Value.PropertyList["PropertyName"]); Console.WriteLine("Current value: {0}", kvp.Value.PropertyList["Value"]); // Change value. embeddedProperties["IsActive"]["Value"].StringValue = allowResponse; Console.WriteLine("Setting the {0} value to {1}.", kvp.Value.PropertyList["PropertyName"], allowResponse); } } // 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" 。 |
allowResponse |
管理: String |
用于设置分发点是否响应 PXE 请求的值。 - 0 - 分发点不响应 PXE 请求。 - 1 - PXE 服务点响应来自未知计算机的请求。 |
编译代码
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站点控制文件