OSD Tattooer Script
osd tattoo powershell district


Latest version  = 1.4.3


Version 1.4.3 is out! (16/08/2015)

 I have added the following minor changes in version 1.4.3:

  • Added Online help. Use get-help .\New-OSDTattoo.ps1 -Online to get the latest help, version of the script, and other infos (Will redirect you to this page).
  • Commented OSDVuildVersion TS variable out.

See lower for download link

Version 1.4.2 is out! (14/04/2015)

I have done a very small modification to the variables names that where tattooed. It fixes a small bug that would Pop up when we would try to Import the WMI class in ConfigMgr when extending the Hardware Inventory.

The following two Tattoos have been renamed:

  • PSDistrict_TaskSequenceName became –> PSDistrict_TSName
  • PSDistrict_TaskInstallationID became –> PSDistrict_TSId

See lower for download link

Version 1.4.1 is out! (15/02/2015)

I have received some great feedback recently concerning the OSD Tatooer. The version 1.4 is now uploaded to Technet.

  • minor bug corrections (Change Root Switch To string).
  • Added WMI instance Creation.

Version 1.1 is out!:

I have added the following features in version 1.1 (01/16/2015):

  • Root switch

This will allow to specify the name of the root registry hive / WMI Class.

  • Correction of minor bugs
  • Updated Comment based help

See lower for download link


 

Download Script

You can download immediately the latest version here from technet here (And PLEASE rate this script on technet by clicking on the Yellow stars) –> Technet

Continue reading to see how this solution works.


 

OSD Tattooer Script

Are you a deployment engineer, or are you working with Operating System deployment and are you using ConfigMgr to do so and you need to tattoo information into your windows image? This blog post is exactly what you are looking for!

It is a common practice to tattoo the Windows Image during OSD to have global information of your image into your final build machine. This helps to identify information such as different versions of image, which task sequence has been used, when it got installed, who initiated the process how long the task sequence execution was etc.. Actually, only your imagination will limit your tattooing needs here.

The following script I am sharing here is a script that will be the most useful for all the deployment engineers.

I will demonstrate in this post how we can tattoo the following places very easily using Powershell:

  • Registry
  • Environment variables
  • WMI repository

As a side note I have tested this script on Configmgr 2012 but it should also work on ConfigMgr 2007. Let me know how it work for you by commenting in the comment section below!

How to OSD tattoo your Windows image?

The process is pretty straight forward, simply follow the next 3 steps and that should do the trick 🙂

1)Download the script:

First things first, you will need the New-OSDTatoo.PS1 script. You can download it here under. (and also rate it by clicking on the yellow stars ;)).

Download the New-OSDTattoo.ps1 script here –> Technet

 

2)Create a Package:

Create a SCCM package without a program with the New-OSDTattoo.ps1 script, and upload it to your desired distribution points.

 

3)Create a PowerShell step in the task sequence:

Create a powershell execution script at the end of your task sequence and and add your package to it.

Run powershell ScriptAnd add the  package to the task and call it as follow:

Task sequence

In the example above, we are tattooing the variables only into the registry.

And that’s it! Simple isn’t it? (See the example below to fine tune things a bit more for your environment).

How to Tattoo OSD information using PowerShell?

In order to be able to specify a Registry root and/or a WMI class name, you will have to call the script the fallowing way.

Osd tattoo

The example above will tattoo the OSD information using the switch “All” in the root named “BPUG“.The “All” switch will tattoo the information in the following locations:

  • Registry (HKLM:\Software\<ValueOfroot>)
    • HKLM:\Software\BPUG
  • WMI Repositroy (Root\Cimv2\<ValueOfRoot>)
    • Root\Cimv2\BPUG
  • Environment variables (Root has no influence here).

The Root switch is only available in the version 1.1 of OSDTattooer script. Be sure to have downloaded the latest one.

Download the New-OSDTattoo.ps1 script here –> Technet

How to osd tattoo the registry during SCCM OSD deployment?

In order to tattoo the registry, we will use the New-OSDTattoo.ps1 script I wrote that you can download here.

If you use the script New-OSDTattoo.ps1  it will be a peace of cake!

Simply add a PowerShell Script step in your Task sequence and call the script as followed:

This would be the an example of the result you would get:

powershell osd tattoo-results-registry configmgr

How to osd tattoo the WMI repository during SCCM OSD deployment?

 

Again, If you use the the script New-OSDTatoo.ps1 , it will be a peace of cake!

Simply add a PowerShell Script step in your Task sequence and call the script as followed:

This would be an example of the results you could get:

osd-tattoo-results-wmi-class

 

I used some functions from the WMI-Module I wrote some time back for this section. Here under you will find a bit more information on WMI in general and WMI related information.

If you have no understanding of WMI and are curious to learn the basics from scratch, I recommend you take a look at this WMI introduction presentation I have done for the Bengalore PowerShell usergroup. The link is right here –> PSBUG WMI introduction

Also, have a look at the WMI week articles I wrote. They they could be handy if you need to use powershell + wmi –> WMI Week.

If you are interested in WMI, you can take a look and see how I did here –> WMI-Commands.psm1

 

How to osd tattoo Windows environment variables during SCCM OSD  deployment?

If you want to set environment variables in SCCM during OSD deployment, use the script New-OSDTatoo.ps1 I wrote , it will be a peace of cake!

Simply add the tattoo script step in your Task sequence and call the script as followed:

This could be an example that you could have:

powershell osd tattoo results environment variables configmgr

 

Of course,  you could have added the -Root “YourPrefix” switch. It would have then named the main class / registry hyve “YourPrefix“. (You can change this value to anything that suites you own needs, like your company name for instance). In this case, it was left to the default, which starts with psdistrict_ and which works just fine 🙂

As a side note, if the -Root switch is not specified, the default value name of the hyve / WMI class will be OsBuildInfo (So your tattooed information will be in HKLM:\software\OsBuildInfo if you do not specify any value for Root).

 

Script details:

The script is pretty easy to understand actually, and there is not much to be changed in it in order to be adapted to your own (or client(s)) environment.

By default, I set the following information in the tatoo mechanism:

So this tattoos the TaskSequence installation name, Boot image version, DeploymentID, Installation Method, TaskSequence Installation ID, the SCCM Site code that it is assigned to, and the current build version.

As you can see, almost all of these variables are read only variables. (See the following post on more information on Task Sequence variables –> Task sequence variables )

Each of the variables start with a prefix which is oringinaly set to $PSDistrict_ as you can see from line 592 to 598.

PsDistrict prefix

You can add any other OSD default variable to this list, easily by adding a new line respecting the prefix.

How to add a custom osd variable to a Windows Image?

This became actually very easy with the New-OSDTatoo.ps1 script. If you have an custom HTA in your task sequence where you can set different variables that will later on then be read by your Task sequence in order to do conditional actions, you can use the script in order to tatoo these custom variables as well.

Indeed, the important point here, is that they respect the prefix naming convention, which in the original case of this script is PSDistrict. In other words the, if you create a variable in your HTA that you would like to be tatooed into your Windows Image, all you need to do is to add a prefix to your variable. Easy isn’t? still not clear? let’s go through it together with an example.

Example:

This example might make it more clear. Let’s say you have a custom variable call “InstalledBy” that you would like to be tatooed into your registry so you can track which technician has deployed a PC.

Let’s say that this variable is already existing, and you just want to tatoo it in your registry, either change the variable name like follow: PSDistrict_InstalledBy

or, copy the old InstalledBy variable into a new variable called PSDistrict_InstalledBy and that’s it. The script will add all the variables that have a prefix of PSDistrict_ as a tatoo value. This makes it very easy to add new tatoos in your image because you will only need to worry about the new variables you will add during your task sequence, and the ones that are prefixed correctly, will automatically be written to either the registry, WMI repository, as environment variable, or simply all of them.

[stextbox id=”note”]The prefix could potentially be changed to the one you like by modifying it directly in the script. I would recommend though, that in order to keep things easy you stick with the default prefix .[/stextbox]

Download script:

The complete script listing is located here under, but you can download the script directly from technet on the download link here under.

I have removed the script listing which allows me to maintain code at only one place; Technet. Please use the link below to get the latest version of the script.

Download the New-OSDTattoo.ps1 script here –> Technet