Script to tattoo the client registry during OSD

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 Comments

Add a Comment

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