Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

Script to tattoo the client registry during OSD

Posted on August 15, 2012 by Jörgen Nilsson

I have been using different script and solutions to tattoo the registry during OSD with useful information. There was a question a while ago on Technet forum for a script that could be used to tattoo the registry with Task Sequence variables values it can be found here: http://social.technet.microsoft.com/Forums/en-US/configmanagerosd/thread/24cd277c-d8cb-4dad-a10e-a087a2e5a791/#7d11e483-83a4-4d97-9721-f6a359f6717f

After that I have been using it myself a couple of times to tattoo the client registry during OS deployments, rewrote it a bit and here it is:

I write some values in the Task Sequence which I the pick up in the script like Clientversion, TSVersion like this:

osdtatoo1

The script then simply picks up the Task Sequence variables you are interested in and writes it to the registry like below. It is then really simple to extend the HW inventory in Configuration Manager to include the newly created registry key and then you can create your own reports for when computer where installed and of course used to populate collections.

Then you can create a collection if all computers deployed with a specific version of the TS for instance and target it with updates.

The script will create a registry key for you under HKEY_Local_Machine\Software,  just change the value in the script.

osdtatoo3

To implement it:

1. Modify the script to create a registry key with a name of your choice,  strKeyPath = “SOFTWARE\CCMEXEC”
2. Create a package containing the script
3. Add the two task sequence variables I use above if you don’t edit the script. TSversion and Clientversion
4. Add Run command line step in the TS after the Setup Windows and Configuration Manager step( as we want to be in the installed OS) that runs the script.

Then you are ready to test the script.

It is really easy to add more variables to the script if you need to, here is the list of all available built in TS variables: http://technet.microsoft.com/en-us/library/hh273375.aspx

The script, can be downloaded in a text file here as well: Download

' Sample script to Tattoo the registry during a SCCM task seqeunce with usefull information

' Written by Jorgen@ccmexec.com

dim osd
dim oreg
dim strkeypath
Dim env
const HKEY_LOCAL_MACHINE = &H80000002
set env = CreateObject("Microsoft.SMS.TSEnvironment")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
'Variables
'Main Registry Key path
strKeyPath = "SOFTWARE\CCMEXEC"
'Values
IntallDateTime = formatdatetime(date,2) & " " & formatdatetime(time,3)
AdvertisementID = env("_SMSTSAdvertID")
Organisation = env("_SMSTSOrgName")
TaskSequenceID = env("_SMSTSPackageID")
Packagename = env("_SMSTSPackageName")
MediaType = env("_SMSTSMediaType")
TSVersion = env("TSVersion")
ClientVersion = env("Clientversion")
MachineName = env("_SMSTSMachineName")
Installationmode = ("_SMSTSLaunchMode")
'Create the main Registry Key
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
'Write Values to the Registry
Call writereg ("Installed Date", IntallDateTime)
Call writereg ("AdvertisementID",AdvertisementID)
Call writereg ("Organisation",Organisation)
Call writereg ("Task Sequence Name",Packagename)
Call writereg ("Media Type",MediaType)
Call writereg ("Task Sequence version",TSVersion)
Call writereg ("Client Version", ClientVersion)
Call writereg ("Computername", MachineName)
Call writereg ("Installation Type", Installationmode)
'----------- Write to registry ---------------
Function writereg(strValueName, strValue)
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
End Function

' Sample script to Tattoo the registry during a SCCM task seqeunce with usefull information

' Written by Jorgen@ccmexec.com

dim osd

dim oreg

dim strkeypath

Dim env

const HKEY_LOCAL_MACHINE = &H80000002

set env = CreateObject("Microsoft.SMS.TSEnvironment")

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

'Variables

'Main Registry Key path

strKeyPath = "SOFTWARE\CCMEXEC"

'Values

IntallDateTime = formatdatetime(date,2) & " " & formatdatetime(time,3)

AdvertisementID = env("_SMSTSAdvertID")

Organisation = env("_SMSTSOrgName")

TaskSequenceID = env("_SMSTSPackageID")

Packagename = env("_SMSTSPackageName")

MediaType = env("_SMSTSMediaType")

TSVersion = env("TSVersion")

ClientVersion = env("Clientversion")

MachineName = env("_SMSTSMachineName")

Installationmode = ("_SMSTSLaunchMode")

'Create the main Registry Key

oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

'Write Values to the Registry

Call writereg ("Installed Date", IntallDateTime)

Call writereg ("AdvertisementID",AdvertisementID)

Call writereg ("Organisation",Organisation)

Call writereg ("Task Sequence Name",Packagename)

Call writereg ("Media Type",MediaType)

Call writereg ("Task Sequence version",TSVersion)

Call writereg ("Client Version", ClientVersion)

Call writereg ("Computername", MachineName)

Call writereg ("Installation Type", Installationmode)

'----------- Write to registry ---------------

Function writereg(strValueName, strValue)

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

End Function

9 thoughts on “Script to tattoo the client registry during OSD”

  1. Louis says:
    October 23, 2012 at 8:10 pm

    I found this VERY helpful. I modified how it was execute slightly. We use MDT and I put it in the %deployshare% folder that we use for a few other scripts. Works great.

    Thanks!!!!!

    Reply
  2. JABO says:
    December 5, 2012 at 1:54 pm

    Hi

    Do you also have an example on how to get this information from computers with the reporting feature in SCCM 2007?

    I’m thinking about what to editing/type in the SMS_DEF.MOF and Configuration.MOF, then the query for the report to show this information for all computers?

    So that we can run reports to see when the computers were deployed, what version of the task sequence it was deployed with and so on.

    Thank you very much 🙂

    Reply
  3. JABO says:
    December 5, 2012 at 4:25 pm

    will this work with SCCM 2007?

    Reply
    1. Jörgen Nilsson says:
      December 13, 2012 at 9:20 pm

      Yes, it works just fine with SCCM 2007
      /Jörgen

      Reply
  4. JABO says:
    December 6, 2012 at 10:39 am

    I can see that all the TS variables are valid for SCCM 2007 and it worked there also 🙂 the only issue was that “Disable 64-bit file system redirection” enabled in TS does not seem to work. If we have redirection it works but then it goes to Wow6432Node.

    Reply
  5. JABO says:
    April 3, 2013 at 8:58 am

    Hi Jörgen

    Is it possible to make all the clients register the IntallDateTime in the same format (DD.MM.YYYY HH:MM:SS)? The computers deployed have different regional settings so they are writing this information in different formats and that makes it very hard to sort the “Tattoo report” on the deployment time for computers. Thank you.

    Reply
  6. stephane says:
    January 6, 2015 at 9:40 am

    Hey Jörgen,

    A bit old, but I have actually written recently a similar script to yours in PowerShell which gives you the choice to either tattoo information in the registry, WMI repository, or environment variable (or all at the same time). I leave the link here for the ones that are interested in it 🙂

    http://powershelldistrict.com/osd-tattoo-powershell/

    Reply
  7. Eden Oliveira says:
    January 15, 2015 at 10:30 pm

    Hi Jörgen, First of all, thank you for your contribution for all of us.

    I am a bit confused how I could apply this solution to my SCCM 2012 R2 environment.

    Would be able to tell me where I should place this script on my Task sequence? Since I have a MDT integrated with my SCCM, the steps are different from yours and I dont know exactly before which step I should place the script.

    Other question is, should I create a package with no Program?
    What type of step should it be? would it be a “new task sequence variable” or a “run command line”

    Thank you for your help in advance.

    Eden Oliveira

    Reply
  8. Rodrigo Sahb says:
    July 15, 2016 at 5:05 pm

    Jörgen how are you?

    To apply Script to tattoo the customer record during OSD does not need to run a command type Cscript.exe to run the command .vbs script?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • Tip when troubleshooting unexpected reboots during Autopilot – event ID 2800
  • New settings in Intune Security Baseline Windows 11 24H2 -2504
  • Managing extensions in Visual Studio Code
  • Reinstall a required Win32app using remediation on demand
  • Administrator protection in Windows 11 – First look
©2025 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT