Issue

A customer has a requirement for the build process to send an e-mail to their service desk once the build process has completed.

The e-mail message should include the following workstation information:

  • Workstation Name
  • OS
  • Project
  • Machine Type
  • IP Address(s)

Requirements

  • Imaging Toolkit

  • SMTP server allowing connections from workstations

  • Firewall client (if used) configured to allow SMTP connections from the workstation to SMTP server

Solution

Update / modify Phase4-after.vbs script file to send an e-mail message at the end of the build process.

Process

WARNING! Do NOT perform this procedure in a production environment without first fully testing in a non-production test environment.
  1. Launch Build console

  2. Open your project xml file

  3. Select "Expert View"

  4. Select "Customisations" - "Custom Files"

  5. Right click on phase4-after.vbs - then select "Edit"

  6. Update the file to reflect the following changes.

    The SMTP configuration values highlighted in red need to be updated with information appropriate to your environment:

    ' ENGL Imaging Toolkit
    ' Copyright (C) 1999-2010 Expert Networking Group Limited
    
    ' ENGL TID 2010023 https://englnet.engl.co.uk/kb/tid-2010023.htm
    ' Custom script template (phase4-after.vbs)
    
    
    ' Attach to ENGL Ztoolkit ActiveX Control
    Set LDAP= CreateObject("ENGL.Ztoolkit.LDAP")
    Set Utils= CreateObject("ENGL.Ztoolkit.Utils")
    Set ZENworks= CreateObject("ENGL.Ztoolkit.ZENworks")
    Set WshShell= WScript.CreateObject("WScript.Shell")
    
    ' Set ZISD Version
    ZENworks.ZISDVersion = 11
    
    ' Identify workstation information from zisd
    zisd_computername = ZENworks.GetZisdAttributeValue("NetBiosName")
    
    ' Read in ZISD:VendorDataENGL
    VendorDataENGLSTRING  = ZENworks.GetZisdAttributeValue("VendorDataENGL")
    
    zisd_machine_type = Utils.GetKeyPairStringValue(VendorDataENGLSTRING, "Machine_Type")
    zisd_os = Utils.GetKeyPairStringValue(VendorDataENGLSTRING, "OS")
    zisd_project = Utils.GetKeyPairStringValue(VendorDataENGLSTRING, "project")
    
    ' Send email to Service Desk to say a machine has been built
    utils.appendlog "Sending e-mail to Service Desk to say a machine has been built"
    
    ' Identify ip address(s)
    
    strComputer = "."
    Set objWMIService = GetObject( _
        "winmgmts:\\" & strComputer & "\root\cimv2")
    Set IPConfigSet = objWMIService.ExecQuery _
        ("Select IPAddress from Win32_NetworkAdapterConfiguration ")
    
    For Each IPConfig in IPConfigSet
        If Not IsNull(IPConfig.IPAddress) Then
            For i=LBound(IPConfig.IPAddress) _
                to UBound(IPConfig.IPAddress)
                   email_ipaddress = email_ipaddress & IPConfig.IPAddress(i) &" " & vbCrLf
            Next
        End If
    Next
    
    ' SMTP configuration
    smtp_sender = "sender@email"
    smtp_recipients = "recipient@email"
    smtp_server = "smtp_server"
    smtp_server_port= "25"
    smtp_user= "sender user (If required)"
    smtp_user_pwd= "sender password (If required)"
    
    ' Compose e-mail message
    email_subject = "Machine "& zisd_computername &" - has been built successfully"
    email_body = vbCrLf & _
      "The following workstation has been built successfully" & vbCrLf & _
      "Workstation Name : " & zisd_computername & vbCrLf & _
      "OS    : " & zisd_OS & vbCrLf & _
      "Project    : " & zisd_project & vbCrLf & vbCrLf & _
      "Machine type    : " & zisd_machine_type & vbCrLf &_
      "IP Address(s)    : " & email_ipaddress & vbCrLf & vbCrLf
    
    ' Configure e-mail
    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = email_subject
    objMessage.Sender = smtp_sender
    objMessage.To = smtp_recipients
    objMessage.TextBody = email_body
    
    ' Uncomment the following line to attach ztoolkit.log file to email
    'objMessage.AddAttachment "c:\ztoolkit\ztoolkit.log"
    
    
    ' This section provides the configuration information for the SMTP server.
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    
    'Name or IP address of SMTP server
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtp_server
    objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = smtp_server_port
    objMessage.Configuration.Fields.Update
    
    ' Uncomment the following lines to send authentication details to the SMTP server
    'objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = smtp_user
    'objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = smtp_user_pwd
    
    ' Send the e-mail
    objMessage.Send


  7. Save the changes to the phase4-after.vbs script

  8. Run Deployment Wizard - recreate the buildprocess image (ztoolkit.zmg)

  9. Copy the updated ztoolkit.zmg file onto the appropriate location on the imaging server

  10. Test the updated build process to confirm it is completing and that the service desk is receiving an e-mail