Having Tattoo add additional information
-
Wednesday, May 23, 2012 2:45 PMI am looking to run a powershell script to query WMI or the registry based off the deployment server selected. I have linked deployments and would need a new sequence or for the tattoo sequence to add information such as which deployment server was used. I'm currently using the LocationServer.xml file for it the list to populate. It appears that the tattoo sequence does add some info but not the server used. What do I need to add to the ZTITatoo.mof and ZTITatoo.wsf to make this happen? Thanks in advance!
All Replies
-
Wednesday, May 23, 2012 7:41 PM
I added a second ZTITatooCORP task to add my own info, just to keep the stock scripts clean. Anything you can script you can add, and this will log to the standard location:
<job id="ZTITatooCORP">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">' // ***************************************************************************
' //
' // Copyright (c) Microsoft Corporation. All rights reserved.
' //
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File: ZTITatooCORP.wsf
' //
' // Version: 5.1.1642.01
' //
' // Purpose: Tattoo the machine with identification and version info
' //
' // Usage: cscript.exe [//nologo] ZTITatooCORP.wsf [/debug:true]
' //
' // ***************************************************************************
Option Explicit
RunNewInstance
'//----------------------------------------------------------------------------
'// Global Constants
'//----------------------------------------------------------------------------
' No constants are required
'//----------------------------------------------------------------------------
'// Main Class
'//----------------------------------------------------------------------------
Class ZTITatooCORP
'//----------------------------------------------------------------------------
'// Class instance variable declarations
'//----------------------------------------------------------------------------
' No instance variables are required
'//----------------------------------------------------------------------------
'// Constructor to initialize needed global objects
'//----------------------------------------------------------------------------
Private Sub Class_Initialize
' No initialization is required
End Sub
'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------
Function Main
Dim iRetVal
Dim sValue
Dim oDate
Dim sMOFFile
Dim sCmd
Dim MyxmlDoc, arrWIMpath, strWIMname
iRetVal = Success
' Make sure we're really in the full OS
If oEnvironment.Item("OSVersion") = "WinPE" then
oLogging.ReportFailure "ERROR - ZTITatooCORP state restore task should be running in the full OS, aborting.", 9601
End if
'//----------------------------------------------------------------------------
'// Copy and compile the MOF
'//----------------------------------------------------------------------------
iRetVal = oUtility.FindFile("ZTITatoo.mof", sMOFFile)
If iRetVal <> Success then
oLogging.CreateEntry "Unable to find ZTITatoo.mof, information will not be available via WMI.", LogTypeInfo
Else
oLogging.CreateEntry "Copying " & sMOFFile & " to " & oEnv("WINDIR") & "\SYSTEM32\WBEM\ZTITatoo.mof.", LogTypeInfo
If oFSO.FileExists(oEnv("WINDIR") & "\SYSTEM32\WBEM\ZTITatoo.mof") then
oFSO.GetFile(oEnv("WINDIR") & "\SYSTEM32\WBEM\ZTITatoo.mof").Attributes = 0
End if
oFSO.CopyFile sMOFFile, oEnv("WINDIR") & "\SYSTEM32\WBEM\ZTITatoo.mof", true
sCmd = oEnv("WINDIR") & "\SYSTEM32\WBEM\MOFCOMP.EXE -autorecover " & oEnv("WINDIR") & "\SYSTEM32\WBEM\ZTITatoo.mof"
oLogging.CreateEntry "About to compile MOF: " & sCmd, LogTypeInfo
iRetVal = oShell.Run(sCmd, 0, true)
oLogging.CreateEntry "MOFCOMP return code = " & iRetVal, LogTypeInfo
End If
'//----------------------------------------------------------------------------
'// Read the unattend.xml
'//----------------------------------------------------------------------------
oLogging.CreateEntry "Reading unattend.xml to find WIM name", LogTypeInfo
Set MyxmlDoc = CreateObject( "Microsoft.XMLDOM" )
MyxmlDoc.Async = "False"
MyxmlDoc.Load(oEnv("WINDIR") & "\Panther\unattend.xml")
REM Get the WIM name from the unattend.xml file and split it into component paths & a file name.
arrWIMpath = split(MyxmlDoc.selectSingleNode("/unattend/settings/component/ImageInstall/OSImage/InstallFrom/Path").Text, "\")
strWIMname = arrWIMpath(ubound(arrWIMpath))
oLogging.CreateEntry "Writing WIM name value to HKLM\Software\CORP\ImageName", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\ImageName", strWIMname, "REG_SZ"
'//----------------------------------------------------------------------------
'// Record the deployment details
'//----------------------------------------------------------------------------
oLogging.CreateEntry "Writing values to HKLM\Software\CORP key", LogTypeInfo
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Task Sequence ID", oEnvironment.Item("TaskSequenceID"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Task Sequence Name", oEnvironment.Item("TaskSequenceName"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Task Sequence Version", oEnvironment.Item("TaskSequenceVersion"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Deployment Method", oEnvironment.Item("DeploymentMethod"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Deployment Type", oEnvironment.Item("DeploymentType"), "REG_SZ"
Set oDate = CreateObject("WbemScripting.SWbemDateTime")
oDate.SetVarDate(Now())
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Deployment Timestamp", oDate.Value, "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\DeploymentLocation", oEnvironment.Item("Location001"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\DeploymentShare", oEnvironment.Item("DeployRoot"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\HostName", oEnvironment.Item("Hostname"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\SerialNumber", oEnvironment.Item("Serialnumber"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Make", oEnvironment.Item("Make"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\Model", oEnvironment.Item("Model"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\IsLaptop", oEnvironment.Item("IsLaptop"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\IsDesktop", oEnvironment.Item("IsDesktop"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\IsVM", oEnvironment.Item("IsVM"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\UserID", oEnvironment.Item("UserID"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\UserDomain", oEnvironment.Item("UserDomain"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\DomainJoinAcct", oEnvironment.Item("DomainAdmin"), "REG_SZ"
oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\CORP\DomainJoinAcctDomain", oEnvironment.Item("DomainAdminDomain"), "REG_SZ"
Main = iRetVal
End Function
End Class
</script>
</job>
-
Thursday, June 07, 2012 8:00 PMHi JoeZeppy! That looks very promising :) I'll give it a try and provide feedback. Thanks again.
-
Wednesday, June 20, 2012 6:18 PMHow did this work for you?
-
Friday, June 22, 2012 7:16 PMSorry for the delay in trying out your script. I created a one liner task sequence and received an error...I'm thinking it may have to be part of a full deployment in order for it to work. I'm on vaca next week so I wil try it when I get back. I appreciate you checking in.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
-
Friday, September 14, 2012 2:07 PM
I created a Post OS Installation Task with Command Line: cscript.exe "%SCRIPTROOT%\ZTITatooCorp.wsf" /debug:true and am getting the following errors:
I tried adding BDD log but it kept rejecting...maybe because there is too many characters.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
- Edited by Hans Lima Wednesday, January 09, 2013 7:58 PM
-
Wednesday, September 19, 2012 8:06 PM
Error 1 is usually something pretty fundamental. The task just didn't work. Could be a typo in the command line, an error in the script, etc.
Is IDG_ZTITatooCorp.wsf a script you wrote? are you sure it works and is error free? Don't forget, if Option Explicit is set, every variable needs to be dimmed before it is used, that one gets me a lot.
-
Wednesday, December 12, 2012 4:21 PM
Hi JoeZeppy.
This script looks great. This is exactly what I am looking for as well! MDT scripting isnt my strong point, so the time you put into this is appreciated.
I am getting the same error as Hans Lima when running a Post OS Install Task using the script exactly as you posted it. I wanted to initally point it to another registry key but when it wasnt working there, I tried using your script exactly how you posted it. That isnt working either I am getting Exit Code 1 in the smsts.log and Incorrect function is listed in the log as well.
I have replaced the existing Tattoo script with this line of code. cscript.exe //nologo "%SCRIPTROOT%\ZTITatooCORP.wsf" /debug:true
I have your script as a WSF file sitting in the MDT Scripts directory. Thanks for your help.
-
Thursday, December 13, 2012 6:01 PM
When I pasted this, I renamed it from ZTITatoo(my company) to a generic ZTITatooCORP.wsf, but in the script I left the class defined as ZTITatoo( my company ). It's possible that was the problem. I edited the script above to change it. So recopy the new one, or confirm that all references in the wsf file are ZTITatooCORP
EDIT:
Check this also - I always forget it because my script editor hides it from me, but you need these XML tags at the very top and bottom of the WSF script ( everything else inside them), and the Job id, the wsf name and the Class should all agree. This allows the wsf file to include the functions defined in ZTIUtility.vbs. I added that up above as well.
<job id="ZTITatooCORP">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">( script goes here )
</script>
</job> -
Thursday, December 13, 2012 8:30 PM
JoeZeppy, I was able to get this to work, but had to make one more adjustment. The last line of the script, "< /job>", was erroring out the script because of the space before the forward slash. I removed the space and now the script works.
Great work! I have a ton of information that we now report on. Thanks for sharing your talents.
-
Thursday, December 13, 2012 8:54 PM
Nice solution JoeZeppy,
I wrote a post not too long ago that might also help.
LTI/ZTI Scripting: MDT Scripting Template
I've posted several other articles on writing registry keys that may help. Hope this helps further.
/Andrew
Blog: http://scriptimus.wordpress.com
-
Thursday, December 13, 2012 9:18 PM
Oops, must have fat fingered it. Fixed it in the script. Thanks!- Proposed As Answer by DaBronze9774 Thursday, December 13, 2012 10:16 PM
-
Thursday, December 13, 2012 10:17 PMThanks Andrew. I've read your stuff also. Excellent work! I'll take a look at that link you sent. Thanks for sharing it.

