The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • about.me

    about.me/mikaelnystrom

  • Archives

  • Meta

Back to Basic – CustomSettings.ini – Explained

Posted by Mikael Nystrom on April 21, 2012

One of the most important files in MDT (and in SCCM with MDT) is customsettings.ini, it is the rule file to rule your deployment. Yesterday Johan and I did a session at MMS and besides getting great scores and that is always fun. During that session I did a couple of demos around customsettings.ini and I would like to explain this a bit more. Because if you do understand the rules you can become much more dynamic and that will hopefully lead to less hassle and more work done in less time.

So, let’s start from the beginning:

When you use the MDT Toolkit (standalone, with WDS, with SCCM, it does not matter) the toolkit will as a part of the process run a script called ZTIGather.wsf, this script will do an asset inventory and also read the customsettings.ini file. This will result in a massive amount of information stored in memory (and in a file) during deployment that we then can use to dynamically update the unattend.xml file on the fly and also control conditions and that way also settings and steps in the TaskSequence

The best thing is that you can run this script without deploying any OS, so this way you can test the rules before you even begin deploying, and you can also test thousands of deployments in a couple of hours. (Here is a blog post on that https://deploymentbunny.com/2011/04/27/quick-and-dirty-testing-customsettings-ini-variables-in-mdt)

CustomSettings.ini – Act I

The basic Customsettings.ini looks like this

In the first row we see the section called [Settings] and this is what the script are looking for and on the next row you can see Priority=Default. That means that it will now consume everything in that section and convert all those lines in to varables in MDT. All the Properties you see under the Section [Default] is built into MDT, there are +100 properties that can be used and most of them are documented in the help file, just search for Properties and you will find a huge list. If we run ZTIGather.wsf against this file we will get the following output

And as you can see, it is using my customsettings.ini file that I pointed out by running cscript.exe ZTIgather.wsf /Inifile:”..\Control\customsttings.ini”, we can also see that the script is reading settings and finding the priority and then process the [Default Section]

CustomSettings.ini – Act II

Now let us assume that you would like to automatically set some settings based on location, things like computer name, language, time zone, something like that In that case, we would use the default gateway as an identifier for the location and would use part of the serial number to calculate a unique name for the computer that is based on the location and the serial number, but hey, let us do something crazy here, let us also add laptop or desktop into the name, so if the laptop is located in Stockholm the name should be STH-LT-0123456 and if a desktop is located in Redmond it would be called RDM-DT-0123456. So, that would look like this

Now, this is slightly “bigger”, but let me guide you through this one, it is not that hard.

The Settings Section

In the [Settings] section we added Init, ByLaptop, ByDesktop and DefaultGateway. The [Init] Section is things that I would like to be set in any situation, like default, but BEFORE default is running. The ByLapTop and ByDesktop contain something called SubSection and we will get back to that. DefaultGateway is a property in MDT so the script will take my current default gateway and match that to what I really have, more on that later.

Next line is the CustomProperties= and here we added a couple of properties that we will fill with data so that we later can use them to populate many variables into one, that’s how we can “build” the computer name, since that will be a combination of computer location + computer type + the first 7 characters in the serial number. So the complete Settings section look like this:

[Settings]
Priority=Init, ByLaptop, ByDesktop, DefaultGateway, Default
Properties=ComputerLocationName, ComputerTypeName, ComputerSerialNumber

The Init Section

The Init section will use the serial number (that has been inventoried by the script already), pick the 7 characters to the left and put that into my custom property ComputerSerialNumber, so that section would look like this: (You can to basically any kind of calculations like this, just go ahead and play with it)

[Init]
ComputerSerialNumber=#Left(“%SerialNumber%”,7)#

The ByLapTop Section and the ByDeskTop Section

These two sections are a bit fun, what we do here is that we tell the script to jump to a subsection called LapTop-%IsLapTop% and %IsLapTop% will either be true or false and we will tell it to do the same for Desktop, and will also return the value of True or False, and since it cannot be a Laptop and an desktop at the same time, either will LapTop-True be true or DeskTop-True be true, so it will pick up regarding case type and then set the name to match that, like this:

[ByLaptop]
SubSection=Laptop-%IsLapTop%
ComputerTypeName=LT

[ByDesktop]
SubSection=Desktop-%IsDesktop%
ComputerTypeName=DT

In my case I have a laptop, so it will set the value of %IsLapTop% to True and the value of %IsDeskTop% to false, resulting in that the ComputerTypeName will be set to LT

The Default Gateway Section

This section will use the value from the gather script regarding the Default Gateway and based on the set jump to the name I have set for that Gateway, so in this case it will go to the section Stockholm if my Default gateway happens to be 10.2.0.4 and in that case it will set the Swedish keyboard and compterlocationname to STH and that part looks like this:

[Stockholm]
ComputerLocationName=STH
UserLocale=sv-SE
UILanguage=sv-SE
KeyboardLocale=041d:0000041d

The Default Section

This section will run last, not because it is last, it will be the last section since it is last on the priority line. That also means that if I have any property value here that has already been set the rule of thumb is that “First Writer Wins”, so they will not be over written (there are exceptions). Here you can see that I have property values for ComputerLocationName and ComputerTypeName, so why do I have that? Well I will set the name to UNK (Short for Unknown) if the computer is not a Laptop and neither a Desktop (Could be a Server? And yes, we could create rules for that to), also if the default gateway is something that I did not add in the customsettings.ini file, and then it will get the location name set to UNK to. So here is how it looks:

[Default]
OSInstall=Y
ComputerLocationName=UNK
ComputerTypeName=UNK
OSDComputername=%ComputerLocationName%-%ComputerTypeName%-%ComputerSerialNumber%
SkipCapture=NO
SkipAdminPassword=YES
SkipProductKey=YES
SkipComputerBackup=NO
SkipBitLocker=NO

The fun part is that OSDcomputername is built by parts of location, type and serial number.

Running the Script will result in this:

 

So, here is how you could create dynamic deployment rules using notepad and a textile, I think that is really cool, but hey, I’m just a Bunny anyway J

(if you would like more samples, let me know…)

/mike

55 Responses to “Back to Basic – CustomSettings.ini – Explained”

  1. Calvin Woods said

    Amazing. You help is fantastic.

  2. Jorge said

    Mikael
    thank you for sharing and giving us your wisdom. I read your blog every time you post an article.
    (if you would like more samples, let me know…) <—- Write a book I'll buy it. Some of us are not fortunate to have SCCM. We can only use MDT. I have the book that you wrote with Johan Deployment Fundamentals V1. It has helped me a lot, but how about you write the sequel of the first book "Extended Deployment Fundamentals V 1.1" in which you share tip and tricks, troubleshooting, deployment to sites without a server, etc. I know if I search online (which i did) I can find all the answer to my question, but it is nicer to have a book to have as a reference any time.

    Oh well! One can dream of such a book.

    Keep posting … we will be reading.
    thanks again.

    Saludos
    Jorge

    • Thank you so much, I can tell you this, we have started to work on Volume number 4, That os going to be MDT 2012, Windows 7 and Windows 8 and we are going to pack it more then ever with “stuff”, we are going add “notes from the filed” and “Behind The Scenes” information, tell me waht you need more specific and we will try to get that in to Volume IV.
      /mike

  3. Patrick Leflar said

    Excellent article! Anyone who is using MDT should read and understand this.
    Went through this last year and took me quite a while to ‘figure it out’ by piecing the documentation together and much trial and error.
    Nice to have this concept well documented in one post.

  4. Excellent write up. Right now I am using task sequence variable to prompt a technician for computer name. Is there a way that I could still propmpt the tech for a name but if the name was blank then it would just use the serial number from the machine as a name?
    Sam

    • As long as the calculation happens before the Wizard runs, you should have no problem, if for example I use the serial number as base for the computer name and you run the LTI wizard, it will show the caluculated name in the dialig box. If you do the name calculation in the tasksequence, well then its harder, the you need to have the wizard do the calculation, it is a bit more tricky, but possible. (And thanks, :-))

      • Thanks for the fast response Mikael, you must have recovered from MMS faster than I did ;-)
        I rechecked and I am actually setting OSDComputerName as a collection variable for all unknown computers. So what you are saying is it should get set at the CS.ini level and then I could choose to change it when prompted during the start of the deployment or is it the other way around?
        Sam

  5. BRB said

    Great article.
    Does this work in MDT 2010?
    ComputerSerialNumber=#right(“%SerialNumber%”,7)#

    Kind regards
    BRB

  6. Fritzroy Guillot said

    This is a great example/tutorial. I have tried following you steps, but I still can not get the computer name to generate properly. Is my TS do I need to tell all of the Gather steps to process rules or just the first gather

    • Two things, number one, every time you try to run the script you need to make sure that delete the MININT folder and post the BDD logfile here

      • Fritzroy Guillot said

        Do you know where I can disable this MDT Configure Computer name wizzard, because I believe it causing my CS.ini not to set the computers
        based on OSDComputername=%ComputerLocationName%-%ComputerTypeName%-%ComputerSerialNumber%

      • Yes, you can skip the Wizardpage by settings SkipComputerName=YES in customsettings.ini but I’m not sure that will help you. I see that you are trying to set the name using OSDComputername=%ComputerLocationName%-%ComputerTypeName%-%ComputerSerialNumber%, so in that case all properties like %ComputerLocationName%, %ComputerTypeName%, %ComputerSerialNumber% must first be set before you can use this combo of name. You should be able to run the ZTIgather script to verify that all is set correctly, no need to deploy a machine to verify this.

  7. Fritzroy Guillot said

    Thanks, I finally got the CS to generate the computer name for me. How can I get the dash removed out of the computer name.
    Example I have computer name MMPOM-V-5494-704. I would like to only have a dash between MMPOMV and the Serial Number So that it would look like this: MMPOMV-5495

  8. Martony said

    Hi Mikael,

    Thanks for those Back to Basic articles. I’m trying to find a way to customize my CS.ini but I’m not sure if it is possible.
    I have modified the Wizard and created a variable called %COMPANY% because I need to customize my deployment depending on the company (JoinDomain, GPOPack….). I added COMPANY in my CS.ini properties but I don’t know how to modify the deployment behavior.
    Is there a way to do this in cs.ini?

  9. […] […]

  10. […] Read the full post here. […]

  11. […] https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ Share this:TwitterFacebookLike this:LikeBe the first to like this. […]

  12. Vik Singh said

    Excellent Write up Mikael. I have worked with you on EBS 2008 Beta (MS – Support for EBS Beta) before and met you in Redmond.

    Just to add, I would add the following in your thread.

    The thumb rule about “First-writer-wins” works for all except for the following properties:
    DeployRoot, ResourceRoot, DeployDrive, ResourceDrive, DeploymentMethod, DeploymentType, Phase, DestinationDisk, DestinationPartition

  13. Jouni J said

    What happens if you set set same property in cs.ini and in mdt database? For example if you set joindomain property in both..which one takes presedence? Actually what i was thinking is situation where you set joinworkgroup=workgroup in Default setting in cs.ini first…this setting would be for workstations that are not added to database. Most of the workstations would be then added to database using their MAC´s. Domain join information would be set in details of workstations in database or in details of Roles.

    In other words if i set Default section first in Settings – Priority in CS.ini would it be so that those settings are set first (for all wks´s) and if there is same setting specified in database (the wks´s set with their mac´s), that setting overwrites the one set in CS.ini default section?

    • Basically all properties has “first” writer wins, so it follows the settings you have in priority in the first section in customsettings.ini. However, if you set the value direct in the tasksequence it will override.

      • Jouni J said

        Is database is read before cs.ini?

      • No, customsettings.ini is the file hat is used first, but it does not mean that the values in customsetting.ini is used, it depends on the first line in customsettings.ini, the Priority=

        In this case, cs.ini defines that it should try to find the the mac, assettag, serialnumber or guid in the database first and if it finds a name in the db, that will be used.

        [Settings]
        Priority=CSettings, Default

        [Default]
        OSDComputrname=BOB

        [CSettings]
        SQLServer=SCVMM01
        Database=MDTPRD01
        Netlib=DBNMPNTW
        SQLShare=MDTPrd$
        Table=ComputerSettings
        Parameters=UUID, AssetTag, SerialNumber, MacAddress
        ParameterCondition=OR

        However, if you switch CSettings and default, the OSDComputername will always be BOB

        [Settings]
        Priority=Default, CSettings

        [Default]
        OSDComputrname=BOB

        [CSettings]
        SQLServer=SCVMM01
        Database=MDTPRD01
        Netlib=DBNMPNTW
        SQLShare=MDTPrd$
        Table=ComputerSettings
        Parameters=UUID, AssetTag, SerialNumber, MacAddress
        ParameterCondition=OR

  14. […] Source:https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ One of the most important files in MDT (and in SCCM with MDT) is customsettings.ini, it is the rule file to rule your deployment. Yesterday Johan and I did a session at MMS and besides getting great scores and that is always fun. During that session I did a couple of demos around customsettings.ini and I would like to explain this a bit more. Because if you do understand the rules you can become much more dynamic and that will hopefully lead to less hassle and more work done in less time. […]

  15. I really had no idea you could do this much with the customsettings.ini file this post is amazing and so clear my boss is really impressed with me (you :P) I got some really great ideas from this thread thank you very much.

  16. […] all we can set our priority and fortunately the ‘deployment bunny’ has written a great blog about the available properties for setting the priority in which order MDT executes which task with […]

  17. mrP!nk said

    is there a way to do further text parsing? In your example you show: LEFT(“%SerialNumber%”,7)#
    Could I collect the 5th,6th and 8th character? If so, where can I find the syntax required to do such manipulation?
    Thanks!

  18. mrP!nk said

    I figured it out, thank you!
    #mid(“%Serialnumber%”,5,1)&mid(“%Serialnumber%”,6,1)&mid(“%Serialnumber%”,8,1)#
    cool stuff, I was creating scripts to do this

  19. ICTspul said

    Thanks for sharing your knowledge Mikael

  20. Darko said

    Ok, I have a question, how can I feed a Power Shell script (computername.ps1) so that output of the script will be computer name? I created a script that will query AD for next available computer so I want to feed that into computer name, is there a way to do this? Also I compile that script in .exe file (coputername.exe) if needed I can feed that as well, but just don’t know how. Thank you.

    • I have no idea, I would instead use a Stored Procedure in the DB or a WebServices to get that information.

    • Darko, if you have the ADSI plugin in your Windows PE image you can query AD (will take some tweaking in your syntax likely) however once you have your “computername” value you can simply set the TS variable OSDComputerName to equal it.
      The powershell code to init the TS environment: $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
      Followed by: $tsenv.Value(“OSDComputerName”) = “YOURVALUEHERE”

      Just ensure you don’t overwrite this value in a later step.

      • Darko said

        Or, you can add PowerShell script that does this: query AD for next available computer name and change the name of current PC with result that came back from query and reboot. (PS script for this is easy to find on net. I wrote one myself since every new PC has number higher then last one joined on domain so it was peace of cake). Add this in TS at the end and should be good.

  21. Erik Dorr said

    I can’t get this to name a desktop properly. It starts every name with an “L”. Has something changed with MDT 2012 update 1?

  22. Johnny said

    Mikael,
    It prefills great, but the workstation never is named correctly…always goes to auto generated one…WIN-XXXX. You have any ideas? Been working on this issue for a while!…any help would be great.

  23. […] CustomSettings.ini – this is used to control OS deployments and is a surprising flexible way of managing OS and application deployments and control of an end-point. If you are using  […]

  24. […] https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ […]

  25. […] Dynamic Variables – this brings some of the common steps that are possible via the customsettings.ini file to the masses…putting the cookies on the bottom […]

  26. […] glory that is the MDT customsettings.ini file, then you need to read Mikael Nystrom’s guide, Back to basics – Customsettings.ini explained. In it, he explains how this file really works, and how to simplify your testing of it. It’s […]

  27. Stephen said

    Mykael, your blog is phenomenal. Thanks so much for the contributions! Is there a way to expand on the example above and place computers from a particular location into separate OU’s based on that location? For example, if a system built in and determined to be in New York and is also a laptop could you place that in a particular OU? if it was a system determined to be a desktop from New York and is also a desktop could that be placed in another OU?

    Thanks!

  28. Stephen said

    Mykael, your blog is phenomenal. Thanks so much for the contributions! Is there a way to expand on the example above and place computers from a particular location into separate OU’s based on that location? For example, if a system built in and determined to be in New York and is also a laptop could you place that in a particular OU? if it was a system determined to be a desktop from New York could that be placed in another OU?

    Thanks!

  29. […] the customsetting.ini file is absolutely new to you, check out : The Deployment Bunny’s Custom Settings.ini Explained Guide or my MDT 2012 CustomSettings.ini Tips & […]

  30. […] https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/http://blogs.technet.com/b/deploymentguys/archive/2009/09/10/using-and-extending-model-aliases-for-hardware-specific-application-installation.aspx […]

  31. […] https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/http://blogs.technet.com/b/deploymentguys/archive/2009/09/10/using-and-extending-model-aliases-for-hardware-specific-application-installation.aspx […]

  32. […] https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ […]

  33. […] Back to Basic – CustomSettings.ini – Explained […]

  34. […] Configure MDTConfigure deployment shares, manage the driver pool, configure task sequences, configure customsettings.iniCreating a deployment share http://bit.ly/1tc6UyxManage drivers http://www.deploymentresearch.com/Research/tabid/62/EntryId/112/MDT-2013-Lite-Touch-Driver-Management.aspxConfigure task sequence MDT http://blogs.technet.com/b/askpfeplat/archive/2014/08/11/mdt-2013-part-ii-create-a-deployment-task-sequence-and-deploy-a-custom-windows-server-2012-r2-base-os-image.aspxConfigure customsettings.ini https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ […]

  35. very useful, thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 7,424 other followers

%d bloggers like this: