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

</script>
</job>

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.

Advertisements

About Andrew Barnes

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

8 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.

    Like

  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.

    Like

  3. Michael Mefford says:

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

    Any ideas?

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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