BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
| |
 |
 |
 |
 |
 |
| Using Tokens and VB Script with Altiris Deployment Server |
 |
|
|
By: Todd Mitchell
Posted On: 4/30/2003
Altiris Deployment Server 5.5 provides a powerful solution for executing client-side scripts (server-side scripting will be available in the upcoming 5.6 release). You can create a library of drag-and-drop events that execute your own custom VB Scripts and/or DOS command language batch files to automated tasks that may extend well beyond Deployment Solution’s initial feature set. If you haven’t yet taken the time to explore how scripting can simplify your windows management efforts, do yourself a favor and spend some time on one of the many websites dedicated to the subject. You’ll be surprised how far scripting can take you.
Deployment Server’s scripting capability is further enhanced by its support for tokens that allow variables to be replaced with their corresponding values at run time. Tokens allow each script to be automatically “customized” for a specific computer or computer group before running.
An example that demonstrates this capability can be seen the simple SendMail script shown below. This script uses the Collaborative Data Objects Messaging (CDO) API to create and send an email. For our example, this email will indicate that a machine has successfully completed a migration to Windows XP.
To try this exercise, open Notepad and type the text below. Save the file on your Deployment Server as “C:\Program Files\Altiris\eXpress\Deployment Server\Scripts\sendmail.vbs”. _______________________________________________________________ Dim Conf If IsEmpty(Conf) Then Const cdoSendUsingPort = 2 Set Conf = CreateObject("CDO.Configuration") With Conf.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "YourSMTPServerIP" .Update End With End If
Dim Message 'As New CDO.Message Dim body
'Create CDO message object Set Message = CreateObject("CDO.Message") With Message 'Set cached configuration Set .Configuration = Conf 'Set email adress, subject And body .To = "youraddress@yourserver.com" .Subject = "Machine %NAME% (console name) has migrated to XP successfully." body = "Current stats for this machine are:" & vbcrlf & vbcrlf body = body & "IP: %NIC1IPADDR%" & vbcrlf body = body & "NetBIOS Name: %COMPNAME%" & vbcrlf body = body & "OS: %OS%" & vbcrlf body = body & "Domain: %DOMAIN%" & vbcrlf body = body & "Manufacturer: %MANUF%" & vbcrlf body = body & "IP Gateway: %NIC1IPGATEWAY%" & vbcrlf body = body & "Altiris Deployment Server: %DSSERVER%" & vbcrlf body = body & "Booted to Production: %DATE% %TIME%" & vbcrlf & vbcrlf body = body & "Thank you for using Altiris products!"
.TextBody = body .From = "yourds@yourserver.com" 'Send the message .Send End With _______________________________________________________________ Once this file is created, open the Deployment Server console and create a custom event. Add a Run Script task to this event and use the conditional filtering options to make sure that this script only executes on the Windows XP operating system. (CDO is native to both Windows 2000 and Windows XP machines but our example calls for the script to run only when a machine has moved to XP). Some scripts are dependent on certain conditions to function correctly. Deployment Server’s filtering capability can make sure that your scripts only execute on those machines whose environments will support them.
In the “Script Task Properties” dialogue box for your Run Script task, select the “Run this script” option and type the following:
REM Send email REM ReplaceTokens .\scripts\sendmail.vbs .\temp\sendmail.vbs \\mydeploymentserver\express\temp\sendmail.vbs
Be sure to indicate that you want the script to execute in Windows and supply a username and password that will have necessary permissions to run your script on the target machine. At runtime, the Deployment Server scripting engine will detect the “ReplaceTokens” command (even though it is on a REM line) and will replace all tokens in the script with their corresponding values from the Altiris database before executing the script on the client
Close out of the Run Script task and use the Altiris console to drag and drop your new event on to a managed XP machine. You should receive an email that has all tokens replaced indicating the current properties of the target computer.
You can place this Run Script task at the end of a Migration Event that rolls out Windows XP, pushes out software, and migrates personalities to indicate that all these jobs were successful. As the last task in any event, this simple send mail task can indicate to you that a job is finished for a target machine. You won’t have to depend on the console for status information as the email will indicate that the job is done. With the improved conditional error handling of Deployment Server 5.6, you can set emails to be triggered based upon very specific error codes.
Altiris Deployment Server’s scripting and token capabilities provide a strong platform for leveraging custom scripts as a management tool. And it’s not limited to Windows. You can drag and drop BASH scripts to manage Linux boxes too . . . all from the same console
|
 |
 |
 |
|
|