MDT 2012 LTI Deployment, Regional and Locale settings based on #chars of Hostname

Recently I have done an MDT implementation for a customer regarding a deployment which featured an database of approx. 250 clients, each with known mac-addresses and host-names available to make use of.

The customer requested that based on mac-address the host-name would be provided, and based on the host-name, Regional and Locale settings could be set during LTI deployment. After a little bit of consult on technet and talked to deployment artist ‘Johan Arwidmark’, I’ve incorporated a custom ‘user exit’ script that does just the trick!

Basically, the company had 5 different affiliate locations in 5 different countries, with each different Regional and Locale settings

The script created/used was a joint effort between a colleague and me, (thanks Roger the Young aka. Drillsergeant):

Explanation of script:

The first 4 lines is our basic UserExit script function, the second function retrieves the CountryCode, and retrieves this information based on the first two characters of the host-name. Last, if no value is declared, the script will automatically fill-in the desired default country, which in our case is NL – Netherlands

The script then executes, and replaces the following values, with the values that are specified in the customsettings.ini:

Make sure you add the following properties to your customsettings.ini: “ByCountry“, “CountryAbbr” (which stands for Country Abbreviation) and define the custom properties: “CountryAbbr“, “CountryOU” as your custom declared properties. This way the script knows what to process.

The values I then had declared were:

CountryOU: since they had different OU’s for each country
CountryOrRegion: Country#
InputLocale: specifies the input language and keyboard layout for a Windows installation.
KeyboardLocale: specifies the input language and keyboard layout for a Windows installation.
UserLocale: specifies the per-user settings used for formatting dates, times, currency, and numbers in a Windows installation.
TimeZoneName: gets the Notification Services assigned name for the time zone

This way, the default values will be overwritten with the values that matches the hostname’s first two characters and the values will be placed in your unattend.xml, which is located in the “C:\Windows\Panther”, during the inital setup of the operating system, just after the image has been applied.

If all fails, you’ll notice immediately because then you will find an error during the setup phase of your operating system, which will look like this:

figure 1.1: Unattended.xml parsing error


This indicates that an incorrect value has been written into the unattend.xml, likeley in the <specialize> pass, you can look this up by opening the unattend.xml with notepad during your deployment.


You can just use any country abbreviation that is out there, accompanied by the default settings for this country, or off-course your own values, and also, extend the list of values with other country related settings you wish to apply.

Download the script here:


12 thoughts on “MDT 2012 LTI Deployment, Regional and Locale settings based on #chars of Hostname

  1. Kevin

    Great article! I have a question. Suppose I want to automatically populate the computer name field with running MDT 2012 Update 1 Lite touch.. What is the best way of automatically populating that field? Your help is appreciated

    1. Rens Hollanders

      Hi Kevin,

      Fully automatic population can best be achieved by integrating a SQL database with MDT. This allows you to store specific per-computer information. So each computer will have it’s own name, based on a relation ship between hostname, and mac-address, uuid, serialnumber or asset tag. Another great thing about using the database is that you can configure roles, locations and specific hardware settings to match with the specific Make and Model for your computer.

      If you want to populate hostnames without a database, you have this script, which sets specific settings based on a number of characters per hostname. But this can be turned around, for example retrieving hostnames based on location and serial number, or retrieved from text file.
      Have a look at Johan Arwidmarks blog: since he has written some good stuff about populating hostnames based on text files to my knowledge.

      Hope this helps!

      Cheers and succes in the wonderfull world of automation!

  2. David

    Hi Rens,

    I can’t seem to get this to work.
    I’m manually entering the computer name at deployment time if that makes a difference?

    This is the relevant part of my customsettings.ini:

    Priority=ByCountry, CountryAbbr, ByLaptopType, Default


    TimeZoneName=GMT Standard Time

    TimeZoneName=Romance Standard Time

    ZTIGetCountry.vbs is in the deployment share’s scripts folder.

    Nothing in the [UK] or [FR] section gets applied. Only the items in [Default] do.

    Even if I set the “fall back” CountryAbbr to be UK only the default settings apply.

    Any idea what I’m doing wrong?

    1. Rens Hollanders


      You should have a look at the bdd.log and smsts.log of a deployment you did or have started to see if the customsettings.ini is processed correct. You can also do this as following without having to start an entire deployment:

      cscript .\scripts\ztigather.wsf /tasksequenceid:OSD001 /inifile:.\control\customsettings.ini

      This would leave a C:\MININT folder with logfiles residing in it on the machine where you have executed the code, which you can view best with Trace64.exe or CMtrace.exe

      Seems to me you have configured it correctly, don’t see anything crazy.

      Oh and especially look for the customproperty being mentioned in the logfile.

      Cheers! Rens

      1. David

        Hi Rens,

        It seems that the ZTIGetCountry.vbs script returns blank values for CountryAbbr because the OSDComputerName variable is not set by the time the script runs – I think it’s because I’m manually entering the name when prompted during deployment.
        I created another UserExit script that runs first and prompts for a computer name. This computer name is then set as the OSDComputerName variable and I’ve enabled SkipComputerName=YES.
        The ZTIGetCountry.vbs is now able to get the values for CountryAbbr. The settings from the relevant [UK] [FR] etc. sections are applied, so it works now.

        Thanks for your help.

        1. Rens Hollanders


          Great to hear. From what I can remember we retrieved the hostname from a database. So I can imagine your situation wouldn’t work if you enter the computername after the user exit script has already been processed.

          Cheers! Rens

  3. Baatch

    RENS! Thank you for an awesome SCRIPT!!

    What is the difference between InputLocale and KeyboardLocale? Do you have to set both? I have seen on other places that you can set InputLocale as fr-FR also and not use 040c:0000040c.

    Also where can I find the CountryOrRegion for all countries?


  4. mik


    Nice script. I was wondering would it be possible to make similar which would choose country prefix based on locale chosen during deployment and then add “-LT/DT-last6 chars of SN.” My only concert is that the locale may not get carried over to the script. Thanks for your input.

    1. Rens Hollanders

      Hi Mik,

      Then you would need to intercept the task sequence variable that sets the country prefix and based on if the machine is a laptop or desktop add the -DT and -LT description to the computer name, again this would mean some scripting which isn’t one of my qualities. I’ve made this script together with out scripting engineer, and it just works this way.

      Cheers! Rens


Leave a Reply

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