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):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
Function UserExit(sType, sWhen, sDetail, bSkip) oLogging.CreateEntry "entered UserExit ", LogTypeInfo UserExit = Success End Function Function GetCountryCode() sFullName = oEnvironment.Item("OSDComputername") sTwoChars = Left(sFullName,2) sCountries = "DE ES FR EN NL" If Instr(sCountries, sTwoChars) Then oLogging.CreateEntry "Computername: " & sFullName & ". Country set to " & sTwoChars, LogTypeInfo GetCountryCode = sTwoChars Else oLogging.CreateEntry "Computername: " & sFullName & ". Country set to Default NL", LogTypeInfo GetCountryCode = "NL" End If End Function |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[Settings] Priority=ByCountry, CountryAbbr, ByModel, ByLaptopType, ByDesktopType, Locations, CSettings, LSettings, MACAddress, Default Properties=CountryAbbr, CountryOU [ByCountry] UserExit=ZTIGetCountry.vbs CountryAbbr=#GetCountryCode()# [NL] CountryOU=NL CountryOrRegion=31 InputLocale=0409:00020409 KeyboardLocale=nl-US UserLocale=nl-NL TimeZoneName=W. Europe Standard Time [DE] CountryOU=DE CountryOrRegion=49 InputLocale=0407:00000407 KeyboardLocale=de-DE UserLocale=de-DE TimeZoneName=W. Europe Standard Time [FR] CountryOU=FR CountryOrRegion=33 InputLocale=040c:0000040c KeyboardLocale=fr-FR UserLocale=fr-FR TimeZoneName=Romance Standard Time |
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.
Concluding:
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.
Thank you so much for this! This is an excellent solution to exactly what I was looking for.
Works great!
Jeff
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
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: deploymentresearch.com 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!
-Rens
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:
[Settings]
Priority=ByCountry, CountryAbbr, ByLaptopType, Default
Properties=CountryAbbr
[ByCountry]
UserExit=ZTIGetCountry.vbs
CountryAbbr=#GetCountryCode()#
[UK]
CountryOrRegion=44
InputLocale=0809:00000809
KeyboardLocale=en-GB
SystemLocale=en-GB
UserLocale=en-GB
UILanguage=en-GB
TimeZoneName=GMT Standard Time
[FR]
CountryOrRegion=33
InputLocale=040c:0000040c
KeyboardLocale=fr-FR
SystemLocale=fr-FR
UserLocale=fr-FR
UILanguage=fr-FR
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?
David,
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
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.
David,
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
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?
THANKS!
Hi,
you are welcome. The difference between inputlocale en keyboardlocale can be viewed here: http://systemscenter.ru/mdt2012.en/inputlocale.htm and here http://systemscenter.ru/mdt2012.en/keyboardlocale.htm
The CountryOrRegion variable is something we have made up ourselves. So you can set it to EN, NL, FR, DE or ES.
Cheers! Rens
Hi,
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.
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
France
TimeZoneName=”Romance Standard Time”
😀