windows-itpro-docs/windows/deployment/deploy-windows-mdt/configure-mdt-for-userexit-scripts.md
VSC-Service-Account 858476cf2f CI Update
2019-06-04 22:13:57 +00:00

3.2 KiB

title, description, ms.assetid, ms.reviewer, manager, ms.author, keywords, ms.prod, ms.mktglfcycl, ms.localizationpriority, ms.sitesec, ms.pagetype, author, ms.date, ms.topic
title description ms.assetid ms.reviewer manager ms.author keywords ms.prod ms.mktglfcycl ms.localizationpriority ms.sitesec ms.pagetype author ms.date ms.topic
Configure MDT for UserExit scripts (Windows 10) In this topic, you will learn how to configure the MDT rules engine to use a UserExit script to generate computer names based on a prefix and the computer MAC Address. 29a421d1-12d2-414e-86dc-25b62f5238a7 laurawi greglin rules, script w10 deploy medium library mdt greg-lindsay 07/27/2017 article

Configure MDT for UserExit scripts

In this topic, you will learn how to configure the MDT rules engine to use a UserExit script to generate computer names based on a prefix and the computer MAC Address. MDT supports calling external VBScripts as part of the Gather process; these scripts are referred to as UserExit scripts. The script also removes the colons in the MAC Address.

Configure the rules to call a UserExit script

You can call a UserExit by referencing the script in your rules. Then you can configure a property to be set to the result of a function of the VBScript. In this example, we have a VBScript named Setname.vbs (provided in the book sample files, in the UserExit folder).

[Settings]
Priority=Default
[Default]
OSINSTALL=YES
UserExit=Setname.vbs
OSDComputerName=#SetName("%MACADDRESS%")#

The UserExit=Setname.vbs calls the script and then assigns the computer name to what the SetName function in the script returns. In this sample the %MACADDRESS% variable is passed to the script

The Setname.vbs UserExit script

The Setname.vbs script takes the MAC Address passed from the rules. The script then does some string manipulation to add a prefix (PC) and remove the semicolons from the MAC Address.

Function UserExit(sType, sWhen, sDetail, bSkip) 
  UserExit = Success 
End Function 
Function SetName(sMac)
  Dim re
  Set re = new RegExp
  re.IgnoreCase = true
  re.Global = true
  re.Pattern = ":"
  SetName = "PC" & re.Replace(sMac, "")
End Function

The first three lines of the script make up a header that all UserExit scripts have. The interesting part is the lines between Function and End Function. Those lines add a prefix (PC), remove the colons from the MAC Address, and return the value to the rules by setting the SetName value.

Note   The purpose of this sample is not to recommend that you use the MAC Address as a base for computer naming, but to show you how to take a variable from MDT, pass it to an external script, make some changes to it, and then return the new value to the deployment process.

Set up MDT for BitLocker

Configure MDT deployment share rules

Simulate a Windows 10 deployment in a test environment

Use the MDT database to stage Windows 10 deployment information

Assign applications using roles in MDT

Use web services in MDT

Use Orchestrator runbooks with MDT