ROVABU NetWorks - ENGL

Appending slmgr.log to ztoolkit.log

In phase4 of an ENGL Imaging Toolkit's build process a device is activated using either a MAK key or KMS server. The activation log is driven by slmgr.vbs and saved in a file called c:\ztoolkit\slmgr.log.

For troubleshooting purposes it might be convenient to have this information in ztoolkit.log as well. This little vbscript, to be run in phase4-after.vbs, appends the slmgr.log to ztoolkit.log:

AppendSlmgrLogfile()

Function AppendSlmgrLogfile

  on error resume next

  Set FSO = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\ztoolkit\slmgr.log",1)
  strSlmgrLogging  = FSO.ReadAll()
  FSO.Close

  Status = Utils.AppendLog("phase4-after.vbs: " & strSlmgrLogging )

  If Err.Number <> 0 then  
    'MsgBox "An error occured in routine AppendSlmgrLogfile()"
    Status = Utils.AppendLog("phase4-after.vbs: " & "AppendSlmgrLogfile()" & " an error occurred " & Err.Number)
  Else
    Status = Utils.AppendLog("phase4-after.vbs: " & "AppendSlmgrLogfile()" & " successfully")
  End If
 
End Function

Appending zac.log to ztoolkit.log

When a device is registered to a ZCM zone in phase2 of the ENGL Imaging Toolkit's build process, the registration log is saved in a file called c:\ztoolkit\zac.log.

For troubleshooting purposes it might be convenient to have this information in ztoolkit.log as well. This little vbscript, to be run in phase2-after.vbs, appends the zac.log to ztoolkit.log:


AppendZacLogfile()


Function AppendZacLogfile

  on error resume next

  Set FSO = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:\ztoolkit\zac.log",1)
  strZacLogging = FSO.ReadAll()
  FSO.Close

  Status = Utils.AppendLog("phase2-after.vbs: " & strZacLogging)

  If Err.Number <> 0 then  
    'MsgBox "An error occured in routine AppendZacLogfile()"
    Status = Utils.AppendLog("phase2-after.vbs: " & "AppendZacLogfile()" & " an error occurred " & Err.Number)
  Else
    Status = Utils.AppendLog("phase2-after.vbs: " & "AppendZacLogfile()" & " successfully")
  End If
 
End Function

Importing certificates during ENGL build process

If you need to import certificates during the ENGL Imaging Toolkit build process, you can use "certutil.exe" which is a Microsoft utility included by default with Windows 7, Windows 8, Windows Server 2008 and Windows Server 2012.

E.g. if you want to import the Oracle certificate which is needed to install the drivers for VirtualBox, you could use this vbscript code to include it in one of the phase scripts (.vbs):

'Import the Oracle Corporation Certificate in order to install VirtualBox 4.x
Utils.Run "certutil -addstore TrustedPublisher ""c:\ztoolkit\oracle corporation.cer""", 0, False

Just make sure to add the certificate itself as a custom file to your ENGL project. You can also import P12 certificates using certutil.exe:

'Import P12 certificates
Utils.Run("certutil -f -importPfx -p ""rovabu"" ""c:\ztoolkit\http_proxy_signing_ca.p12"""),1,True

When "to-be" installed applications in phase3 are depending on these certificates, it's recommended to use a phase1 of phase2 script.

 

Setting a bundle requirement for Windows bundles for virtual machines

Using this vbscript in one of the ENGL phase process 0,1 or 2, you can set a System Variable which reflects where you're working in a Virtual Machine:


IsVirtualMachine = Utils.IsVirtualMachine()

If IsVirtualMachine <> 0 Then
status = Utils.SetSystemEnvironmentVariable("VIRTUALMACHINE", "true")
Else
status = Utils.SetSystemEnvironmentVariable("VIRTUALMACHINE", "false")
End If


Then if you want to install e.g. VMware Tools in phase 3, only on Virtual Machines, you can add this requirement to the Windows bundle:

Environment Variable Value 'VIRTUALMACHINE' Equal to: true

Doing so, this Windows bundle will only be installed on virtual machines and will be skipped on physical machines.

 

Using different OU's for an AD domain join

In phase2 of an ENGL Imaging Toolkit's build process a machine is joined to AD, if you have configured the 'Active Directory / Workgroup' options in your ENGL project.

Sometimes you need to register a device in more than one OU. This little vbscript, to be run in phase2-before, set two variables AD_REGISTRATION_OU and AD_REGISTRATION_DOMAIN. These variables then can be used as %AD_REGISTRATION_OU% and %AD_REGISTRATION_DOMAIN% in your ENGL project.

In this vbscript the default gateway of the IP adapter is being read, using WMI. Based on the default gateway the two variables are set accordingly. You can also use other adapter properties, which are described in this MSDN article about the Win32_NetworkAdapterConfiguration class.

 

SetADRegistrationOU()


Function SetADRegistrationOU

  on error resume next

  Status = Utils.AppendLog("phase2-before.vbs: " & "SetADRegistrationOU()")

  Dim strDefaultGateway
  Dim oDG, oDGs, WMI    

  strDefaultGateway = Empty      
  Set WMI = GetObject("winmgmts:\\.\root\cimv2")  
  Set oDGs = WMI.ExecQuery _  
  ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")  
 
  For Each oDG in oDGs  
    If Not IsNull(oDG.DefaultIPGateway) And Not oDG.defaultIPGateway(0) = "0.0.0.0" Then  
       strDefaultGateway = oDG.DefaultIPGateway(0)  
       Exit For  
    End If
  Next

  Status = Utils.AppendLog("phase2-before.vbs: " & " default gateway is: " & strDefaultGateway)

  select case strDefaultGateway
   case "10.114.0.1"
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_OU", "ou=workstations,ou=rovabu hq,dc=rovabu,dc=nl")
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_DOMAIN", "rovabunetworks.nl")
   case "10.101.0.1"
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_OU", "ou=laptops,ou=rovabu hq,dc=rovabu,dc=nl")
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_DOMAIN", "rovabunetworks.nl")
   case Else
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_OU", "ou=workstations,ou=rovabu hq,dc=rovabu,dc=nl")
     status = Utils.SetSystemEnvironmentVariable("AD_REGISTRATION_DOMAIN", "rovabunetworks.nl")
  end select

  If Err.Number <> 0 then  
    MsgBox "An error occured in routine SetADRegistrationOU()"
    Status = Utils.AppendLog("phase2-before.vbs: " & "SetADRegistrationOU()" & " an error occurred " & Err.Number)
  Else
    Status = Utils.AppendLog("phase2-before.vbs: " & "SetADRegistrationOU()" & " successfully")
  End If
 
End Function