配置 MDT 部署共享规则Configure MDT deployment share rules
2020/3/6
本文内容
在本主题中,了解如何配置 MDT 规则引擎以访问其他资源(包括外部脚本、数据库和 Web 服务),获取额外信息,而不是将设置直接存储在规则引擎中。In this topic, you will learn how to configure the MDT rules engine to reach out to other resources, including external scripts, databases, and web services, for additional information instead of storing settings directly in the rules engine. MDT 中的规则引擎功能强大:用于操作系统部署的大多数设置都是通过规则引擎检索和分配的。The rules engine in MDT is powerful: most of the settings used for operating system deployments are retrieved and assigned via the rules engine. 规则引擎最简单的形式是 CustomSettings.ini 文本文件。In its simplest form, the rules engine is the CustomSettings.ini text file.
分配设置Assign settings
在使用 MDT 时,你可以采用三种不同方法指定设置:When using MDT, you can assign setting in three distinct ways:
你可以在部署前预先暂存信息。You can pre-stage the information before deployment.
你可以提示用户或技术人员获取信息。You can prompt the user or technician for information.
你可以让 MDT 自动生成设置。You can have MDT generate the settings automatically.
为了演示这三个选项,我们来看看一些示例配置。In order to illustrate these three options, let's look at some sample configurations.
示例配置Sample configurations
在添加更多高级组件(如脚本、数据库和 Web 服务)之前,请考虑以下常用配置;它们显示了规则引擎的强大功能。Before adding the more advanced components like scripts, databases, and web services, consider the commonly used configurations below; they demonstrate the power of the rules engine.
按照 MAC 地址设置计算机名Set computer name by MAC Address
如果你具有小型测试环境,或只是想要将设置指定给数量非常有限的计算机,则可以编辑规则,根据给定的 MAC 地址直接指定设置。If you have a small test environment, or simply want to assign settings to a very limited number of machines, you can edit the rules to assign settings directly for a given MAC Address. 如果你具有多台计算机,最好改为使用数据库。If you have many machines, it makes sense to use the database instead.
[Settings]
Priority=MacAddress, Default
[Default]
OSInstall=YES
[00:15:5D:85:6B:00]
OSDComputerName=PC00075
在前面的示例中,你将 MAC 地址为 00:15:5D:85:6B:00 的计算机的计算机名设置为了 PC00075。In the preceding sample, you set the PC00075 computer name for a machine with a MAC Address of 00:15:5D:85:6B:00.
按照序列号设置计算机名Set computer name by serial number
分配计算机名的另一个方法是通过计算机序列号标识计算机。Another way to assign a computer name is to identify the machine via its serial number.
[Settings]
Priority=SerialNumber, Default
[Default]
OSInstall=YES
[CND0370RJ7]
OSDComputerName=PC00075
在此示例中,你将序列号为 CND0370RJ7 的计算机的计算机名设置为了 PC00075。In this sample, you set the PC00075 computer name for a machine with a serial number of CND0370RJ7.
基于序列号生成计算机名Generate a computer name based on a serial number
你还可以将规则引擎配置为使用序列号等已知属性来快速生成计算机名。You also can configure the rules engine to use a known property, like a serial number, to generate a computer name on the fly.
[Settings]
Priority=Default
[Default]
OSInstall=YES
OSDComputerName=PC-%SerialNumber%
在此示例中,你将规则配置为:将计算机名设置为前缀 (PC-) 后跟序列号。In this sample, you configure the rules to set the computer name to a prefix (PC-) and then the serial number. 如果计算机的序列号为 CND0370RJ7,上述配置会将计算机名设置为 PC-CND0370RJ7。If the serial number of the machine is CND0370RJ7, the preceding configuration sets the computer name to PC-CND0370RJ7.
注意Note
使用序列号分配计算机名时请谨慎。Be careful when using the serial number to assign computer names. 序列号可以包含超过 15 个字符,但 Windows 安装程序将计算机名限制为 15 个字符。A serial number can contain more than 15 characters, but the Windows setup limits a computer name to 15 characters.
基于序列号生成受限的计算机名Generate a limited computer name based on a serial number
若要避免分配长度超过 15 个字符的计算机名,可以通过添加 VBScript 函数,更详细地配置规则,如下所示:To avoid assigning a computer name longer than 15 characters, you can configure the rules in more detail by adding VBScript functions, as follows:
[Settings]
Priority=Default
[Default]
OSInstall=YES
OSDComputerName=PC-#Left("%SerialNumber%",12)#
在前面的示例中,你仍将规则配置为:将计算机名设置为前缀 (PC-) 后跟序列号。In the preceding sample, you still configure the rules to set the computer name to a prefix (PC-) followed by the serial number. 但是,添加 Left VBScript 函数后,会将规则配置为仅将序列号的前 12 个字符用于名称。However, by adding the Left VBScript function, you configure the rule to use only the first 12 serial-number characters for the name.
将笔记本电脑添加到 Active Directory 中的不同组织单位 (OU) 中Add laptops to a different organizational unit (OU) in Active Directory
在规则中,你可以找到内置属性,它们使用 Windows Management Instrumentation (WMI) 查询来确定要部署的是笔记本电脑、台式机还是服务器。In the rules, you find built-in properties that use a Windows Management Instrumentation (WMI) query to determine whether the machine you are deploying is a laptop, desktop, or server. 在此示例中,我们假设你想要将笔记本电脑添加到 Active Directory 中的不同 OU。In this sample, we assume you want to add laptops to different OUs in Active Directory. 请注意,ByLaptopType 不是保留字;相反,它是要读取的部分的名称。Note that ByLaptopType is not a reserved word; rather, it is the name of the section to read.
[Settings]
Priority=ByLaptopType, Default
[Default]
MachineObjectOU=OU=Workstations,OU=Contoso,DC=contoso,DC=com
[ByLaptopType]
Subsection=Laptop-%IsLaptop%
[Laptop-True]
MachineObjectOU=OU=Laptops,OU=Contoso,DC=contoso,DC=com
相关主题Related topics