ZTITatoo remake
The Tattoo script that comes with MDT is not working as one would expect when running a x64 OS.
ConfigMgr client put the values to tattoo the registry with under "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Deployment 4\" in the registry. Nothing wrong with that when ConfigMgr read the values since the COnfigMgr client is 32 bit x86.
But if you want to use the same values/variables for instance with a WMI filter when applying a GPO, it wont work. The WMI filter in the GPO will try to read the values under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Deployment 4\"
WMI filter example to get the GPO to only apply to computer that was installed with a specific version of OSImage:
SELECT * FROM Microsoft_BDD_Info WHERE OSDImagePackageID='SMS00001'
This script will correct the ZTITatoo script and put the values/variables in both places in the registry. And also add a few more variables set on some collections. this is of cource editable.
job id="ZTITatoo">
<script language="VBScript" src="ZTIUtility.vbs"/>
<script language="VBScript">
' // ***************************************************************************
' //
' // Copyright (c) Microsoft Corporation. All rights reserved.
' //
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File: ZTITatoo.wsf
' //
' // Version: 5.0.1641.0
' //
' // Own Version: 2.1.0.0
' // 20101025 konjnw: Added logging for vars: KeyboardLocale, SystemLocale, UserLocale
' // TimeZoneName
' // 20101027 konjnw: Complete rewrite of script to support X64 OS
' // Added logging for vars: Language, PCRole, FormFactor
' // 20101028 konjnw: Added logging for vars: OSDImagePackageId, OSDImageVersion, CDAVersion
' //
' // Purpose: Tattoo the machine with identification and version info
' //
' // Usage: cscript.exe [//nologo] ZTITatoo.wsf [/debug:true]
' //
' // ***************************************************************************
Option Explicit
RunNewInstance
'//----------------------------------------------------------------------------
'// Global Constants
'//----------------------------------------------------------------------------
Const HKLM = &H80000002
'//----------------------------------------------------------------------------
'// Main Class
'//----------------------------------------------------------------------------
Class ZTITatoo
'//----------------------------------------------------------------------------
'// Class instance variable declarations
'//----------------------------------------------------------------------------
' No 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 sWbem
Dim sArch
Dim objCtx
Dim objLocator
Dim objServices
Dim objStdRegProv
iRetVal = Success
' Make sure we're really in the full OS
If oEnvironment.Item("OSVersion") = "WinPE" then
oLogging.ReportFailure "ERROR - ZTITatoo task should be running in the full OS, aborting.", 9601
End if
' Check if running in 64 bit OS
If oEnvironment.Item("Architecture") = "X64" Then
sArch = "X64"
Else
sArch = "X86"
End If
Do Until sArch = "Done"
Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
If sArch = "X64" Then
objCtx.Add "__ProviderArchitecture", 64
objCtx.Add "__RequiredArchitecture", True
Else
objCtx.Add "__ProviderArchitecture", 32
objCtx.Add "__RequiredArchitecture", True
End If
Set objLocator = CreateObject("Wbemscripting.SWbemLocator")
Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx)
Set objStdRegProv = objServices.Get("StdRegProv")
'//----------------------------------------------------------------------------
'// 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
sWbem = oEnv("WINDIR") & "\System32\Wbem"
oLogging.CreateEntry "Copying " & sMOFFile & " to " & sWbem & "\ZTITatoo.mof.", LogTypeInfo
If oFSO.FileExists(sWbem & "\ZTITatoo.mof") then
oFSO.GetFile(sWbem & "\ZTITatoo.mof").Attributes = 0
End if
oFSO.CopyFile sMOFFile, sWbem & "\ZTITatoo.mof", true
sCmd = sWbem & "\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
'//----------------------------------------------------------------------------
'// Record the deployment details
'//----------------------------------------------------------------------------
iRetVal = objStdRegProv.CreateKey(HKLM, "Software\Microsoft\Deployment 4")
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Deployment Method", oEnvironment.Item("DeploymentMethod"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Deployment Type", oEnvironment.Item("DeploymentType"))
Set oDate = CreateObject("WbemScripting.SWbemDateTime")
oDate.SetVarDate(Now())
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Deployment Timestamp", oDate.Value)
'//----------------------------------------------------------------------------
'// If this is Lite Touch, populate the task sequence details
'//----------------------------------------------------------------------------
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Task Sequence ID", oEnvironment.Item("TaskSequenceID"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Task Sequence Name", oEnvironment.Item("TaskSequenceName"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Task Sequence Version", oEnvironment.Item("TaskSequenceVersion"))
'//----------------------------------------------------------------------------
'// If this is ConfigMgr, populate the package ID and program name
'//----------------------------------------------------------------------------
sValue = oEnvironment.Item("_SMSTSSiteCode") & ":" & oEnvironment.Item("_SMSTSPackageID")
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Windows NT\CurrentVersion", "CM_DSLID", sValue)
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "OSD Package ID", oEnvironment.Item("_SMSTSPackageID"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "OSD Program Name", "*")
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "OSD Advertisement ID", oEnvironment.Item("_SMSTSAdvertID"))
'//----------------------------------------------------------------------------
'// Own Changes Begin
'//----------------------------------------------------------------------------
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "KeyboardLocale", oEnvironment.Item("KeyboardLocale"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "SystemLocale", oEnvironment.Item("SystemLocale"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "UserLocale", oEnvironment.Item("UserLocale"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "TimeZoneName", oEnvironment.Item("TimeZoneName"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "Language", oEnvironment.Item("Language"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "PCRole", oEnvironment.Item("PCRole"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "FormFactor", oEnvironment.Item("FormFactor"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "CDAVersion", oEnvironment.Item("CDAVersion"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "OSDImagePackageID", oEnvironment.Item("OSDImagePackageID"))
iRetVal = objStdRegProv.SetStringValue(HKLM, "Software\Microsoft\Deployment 4", "OSDImageVersion", oEnvironment.Item("OSDImageVersion"))
'//----------------------------------------------------------------------------
'// Own Changes End
'//----------------------------------------------------------------------------
If sArch = "X64" Then
sArch = "X86"
Else
sArch = "Done"
End If
Loop
Main = iRetVal
End Function
End Class
</script>
</job></pre>
And the mof file.
<pre class="brush:xml">
//==================================================================
// Register Registry property provider (shipped with WMI)
// Refer to WMI SDK documentation for use
//==================================================================
#pragma namespace("\\\\.\\root\\cimv2")
// Registry instance provider
instance of __Win32Provider as $InstProv
{
Name ="RegProv" ;
ClsID = "{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}" ;
ImpersonationLevel = 1;
PerUserInitialization = "False";
};
instance of __InstanceProviderRegistration
{
Provider = $InstProv;
SupportsPut = True;
SupportsGet = True;
SupportsDelete = False;
SupportsEnumeration = True;
};
// Registry property provider
instance of __Win32Provider as $PropProv
{
Name ="RegPropProv" ;
ClsID = "{72967901-68EC-11d0-B729-00AA0062CBB7}";
ImpersonationLevel = 1;
PerUserInitialization = "False";
};
instance of __PropertyProviderRegistration
{
Provider = $PropProv;
SupportsPut = True;
SupportsGet = True;
};
//==================================================================
// BDD Information class and instance definition
//==================================================================
#pragma namespace ("\\\\.\\root\\cimv2")
// Class definition
#pragma deleteclass("Microsoft_BDD_Info",nofail)
[DYNPROPS]
class Microsoft_BDD_Info
{
[key]
string InstanceKey;
string DeploymentMethod;
string DeploymentType;
datetime DeploymentTimestamp;
string BuildID;
string BuildName;
string BuildVersion;
string OSDPackageID;
string OSDProgramName;
string OSDAdvertisementID;
string TaskSequenceID;
string TaskSequenceName;
string TaskSequenceVersion;
string KeyboardLocale;
string SystemLocale;
string UserLocale;
string TimeZoneName;
string Language;
string PCRole;
string FormFactor;
string OSDImagePackageId;
string OSDImageVersion;
string CDAVersion;
};
// Instance definition
[DYNPROPS]
instance of Microsoft_BDD_Info
{
InstanceKey = "@";
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Deployment Method"), Dynamic, Provider("RegPropProv")]
DeploymentMethod;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Deployment Type"), Dynamic, Provider("RegPropProv")]
DeploymentType;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Deployment Timestamp"), Dynamic, Provider("RegPropProv")]
DeploymentTimestamp;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Build ID"), Dynamic, Provider("RegPropProv")]
BuildID;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Build Name"), Dynamic, Provider("RegPropProv")]
BuildName;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Build Version"), Dynamic, Provider("RegPropProv")]
BuildVersion;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|OSD Package ID"), Dynamic, Provider("RegPropProv")]
OSDPackageID;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|OSD Program Name"), Dynamic, Provider("RegPropProv")]
OSDProgramName;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|OSD Advertisement ID"), Dynamic, Provider("RegPropProv")]
OSDAdvertisementID;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Task Sequence ID"), Dynamic, Provider("RegPropProv")]
TaskSequenceID;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Task Sequence Name"), Dynamic, Provider("RegPropProv")]
TaskSequenceName;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Task Sequence Version"), Dynamic, Provider("RegPropProv")]
TaskSequenceVersion;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|KeyboardLocale"), Dynamic, Provider("RegPropProv")]
KeyboardLocale;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|SystemLocale"), Dynamic, Provider("RegPropProv")]
SystemLocale;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|UserLocale"), Dynamic, Provider("RegPropProv")]
UserLocale;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|TimeZoneName"), Dynamic, Provider("RegPropProv")]
TimeZoneName;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|Language"), Dynamic, Provider("RegPropProv")]
Language;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|PCRole"), Dynamic, Provider("RegPropProv")]
PCRole;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|FormFactor"), Dynamic, Provider("RegPropProv")]
FormFactor;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|OSDImagePackageId"), Dynamic, Provider("RegPropProv")]
OSDImagePackageId;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|OSDImageVersion"), Dynamic, Provider("RegPropProv")]
OSDImageVersion;
[PropertyContext("local|HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Deployment 4|CDAVersion"), Dynamic, Provider("RegPropProv")]
CDAVersion;
};