You can also create scripts for use in the imaging process. You call these scripts by adding them to the Task Sequence Editor and ultimately by adding them to the TS.xml file. Listing 13 shows a template for creating custom scripts.

Listing 13. Custom Script Template

<job id="Z-Sample">

<script language="VBScript" src="ZTIUtility.vbs"/>

<script language="VBScript">

 

' //***************************************************************************

' // ***** Script Header *****

' //

' // Solution: Solution Accelerator for Microsoft Deployment

' // File: Z-Sample.wsf

' //

' // Purpose: Template

' //

' // Usage: cscript Z-Sample.wsf [/debug:true]

' //

' // Customer Build Version: 1.0.0

' // Customer Script Version: 1.0.0

' // Customer History:

' //

' // ***** End Header *****

' //***************************************************************************

 

'//----------------------------------------------------------------------------

'//

'// Global constant and variable declarations

'//

'//----------------------------------------------------------------------------

 

Option Explicit

 

Dim iRetVal

 

'//----------------------------------------------------------------------------

'// End declarations

'//----------------------------------------------------------------------------

 

'//----------------------------------------------------------------------------

'// Main routine

'//----------------------------------------------------------------------------

 

On Error Resume Next

iRetVal = ZTIProcess

ProcessResults iRetVal

On Error Goto 0

 

'//---------------------------------------------------------------------------

'//

'// Function: ZTIProcess()

'//

'// Input: None

'//

'// Return: Success - 0

'// Failure - non-zero

'//

'// Purpose: Perform main ZTI processing

'//

'//---------------------------------------------------------------------------

Function ZTIProcess()

 

     iRetVal = Success

 

     ZTIProcess = iRetval

 

     '!!!!!!!!!!!   INSERT YOUR CODE HERE   !!!!!!!!!!!!

 

End Function

 

</script>

</job>

At a high level, complete the following steps to add a custom script:

1.   Create the script based on the template.

2.   Place the script in the Scripts folder of the:

·     Deployment share for LTI deployments

·     Package source for the Microsoft Deployment Toolkit Files package

3.   Create a task sequence step based on the Run Command Line task sequence step type in your task sequence.

4.   Configure the task sequence step created in the previous step to run your script.

Follow these guidelines when creating a script:

·     Always declare variables.

·     Only create objects where required, because MDT includes most objects that are needed.

·     Verify that ZTIUtility.vbs and ZTIDataAccess.vbs do not already provide the functionality required before writing a function.

Related Topics

Creating Custom Scripts for MDT