MDT Scripting: Hello World

This is a simplified version of my Zero-Touch/Lite-Touch scripting guide. MDT Scripts call functions(smaller script routines) from another script called ZTIUtility.vbs. There is a template that takes care of the connections to make life even easier. In short it’s a 2 step process.

Edit the template.

Download the scripting template from here and rename it to something useful. In my example it’s called Test-HelloWorld.wsf. Then save it to Deployment Share\Scripts with a .wsf extension.

Note: I’ve updated this page and included the template here:

<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


Insert your custom code.

Enter this as your custom code. Replacing the INSERT YOUR CODE HERE  line.

wscript.echo “Hello World”

Test the results.

I suggest first booting into WinPE in a virtual Machine. This will give you a simulated environment where you can be pretty sure that your scripts will function correctly.

Press F8 to bring up a command prompt and type:

cscript.exe z:\scripts\Test-HelloWorld.wsf

You will see the echo returned to the console screen as in the illustration below.

Finally navigate to the logs folder and take a look at the log files. You’ll see a new log file created for your script that you just ran. It’s also referenced in the BDD.log file

I’ll post articles on how to write to the logs in the future. So there you have it. You’re now a bonifide MDT/ZTI/LTI scripter.

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in MDT 2010, SCCM, Scripting and tagged , , . Bookmark the permalink.

12 Responses to MDT Scripting: Hello World

  1. JasonL says:

    Great set of guides. Thank you for this. I’ve been wanting to learn more about scripting and MDT for a while now.


  2. Thank you for the quide. However, do i need to use single quotes? wscript.echo ‘Hello World’
    i am getting an error with your string? wscript.echo “Hello World”

    Thank you.


  3. Michael Mefford says:

    I’m trying this, but I keep getting this error: Incorrect Function (Code 00000001)

    Any ideas?


  4. J. Wall says:

    Thanks for this Andrew. Using your example above, when I run the script I can see “Hello World” echoed to the console but when I look in X:\MININT\SMSOSD\OSDLOGS\ I do not see a log for my script. The only files in this directory are:


    Am I missing something obvious?


    • J. Wall says:

      And my script is also NOT referenced in bdd.log…


    • Maybe the code has changed since I wrote this. Post a question in the mdt forum for up to date support.


      • J. Wall says:

        Ok thanks. To be clear, if I run a task sequence which uses my script a log is created successfully, but if I pxe boot to the deployment wizard, press F8 and run my script manually the log is not created.

        Perhaps this is expected behavior and I’m just misunderstanding your instructions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s