Quantcast
Channel: deploymentshare.com - Microsoft Deployment Toolkit
Viewing all articles
Browse latest Browse all 6

Naming by Gateway during ZTI OSD–ConfigMgr

$
0
0

Hello internet!  Here I’m going to delve into the world of automatic computer naming by gateway using ConfigMgr.  Using a reference from Mikeal Nystrom (see links at the bottom of the page)  I’ve got this going with great effect in my environment so I though I’d share.

Firstly, before we go any further you are going to require MDT integration to get this to work.  We will create a MDT Settings package along the way as we create a task sequence and then configure the customsettings.ini to name the devices as we see fit.

So, before we begin we’re going to pre-stage two new folders which is where I want the packages (source) to be stored (I’ll leave the decisions on this up to you) …

image

..and then create a new MDT integrated task sequence.

image

Here are the steps I take:

Chose Template – Client Task Sequence
General– Name the task sequence
Details – Set your own details here as you see fit
Capture Settings– This task sequence will never be used to capture an image
Boot Image– Select your boot image
MDT Package– Create a new Microsoft Deployment Toolkit Files package & browse to to the shared UNC of the folder you set up for the files package
MDT Details– Fill in as required
OS Image– Specify your operating systemimage.
Deployment Method– Perform a “Zero Touch Installation” OS Deployment, with no user interaction
Client Package– Specify your client package
USMT Package– Specify your USMT package
Settings Package– Create a new settings package & browse to to the shared UNC of the folder you set up for the settings package
Settings Details – Set your own details here as you see fit
Sysprep Package– No Sysprep package is required

Now you should have your settings and files packages created and those of you who are familiar with MDT can browse the package source folders and recognise what you’re seeing.   Next we’re going to examine how we’re going to set this up moving forward.   Here is a diagram of my current setup

image

In my situation our main site server is located in a Data Center, it has a WAN link directly to each branch office (of which there are lots!) and in each Branch Office we have a PXE enabled distribution point ready to image OSD Clients.  Each Branch office has its own subnet and in turn, gateway, so if we imagine creating a singular task sequence that can read the gateway address and then apply local settings that suit – That would be awesome!  Lets do that….

First thing we need to do is to crack open customsettings.ini and start programming it as we require.  So if you browse to the sources folder on your site server and locate the folder for the MDT Settings package we created earlier you should see two files.

1. Customsettings.ini
2. Unattend.xml

Open customsettings.ini and lets start editing!!!  Here is how I am going to build up my naming convention.  Four letters to identify the site, followed by a hyphen, followed by a singular letter to denote a laptop, desktop or virtual machine, followed by a hyphen and finally the last 6 digits of the serial number of the machine (some people use the first few digits but in my experience only the last few differ whereas the first few can be the same across multiple machines – this may differ from vendor to vendor please examine the format of SN’s from your vendor carefully).  As an example if my desktop computer was in London, then a generated name example would be LOND-L-123ABC.  Looking at this I can determine where is it and what type of machine it is.  Also, AD is happy because the name is unique as its added on the domain during the process.

Here is a copy of my customsettings.ini

   1: [Settings]
   2: Priority=GenerateSN, Am_I_a_VirtualMachine, Am_I_a_Desktop, Am_I_a_Laptop, DefaultGateway, Default
   3: Properties=SitePrefix, ComputerSerialNumber, ComputerTypeName
   4:  
   5:  
   6:'******  WHOAMI OPTIONS******
   7: [GenerateSN]
   8: ComputerSerialNumber=#Right(Replace(Replace(oEnvironment.Item("SerialNumber")," ",""),"-",""),6)#
   9:  
  10: [Am_I_a_VirtualMachine]
  11: SubSection=VirtualMachine-%IsVM%
  12:  
  13: [Am_I_a_Desktop]
  14: SubSection=Desktop-%IsDesktop%
  15:  
  16: [Am_I_a_Laptop]
  17: SubSection=Laptop-%IsLaptop%
  18:  
  19: [VirtualMachine-True]
  20: ComputerTypeName=V
  21:  
  22: [Desktop-True]
  23: ComputerTypeName=D
  24:  
  25: [Laptop-True]
  26: ComputerTypeName=L
  27:  
  28:  
  29: '****** GATEWAY OPTIONS******
  30: [DefaultGateway]
  31: 192.168.1.1=London
  32: 192.168.2.1=Manchester
  33: 192.168.3.1=Newcastle
  34: 192.168.4.1=Bristol
  35: 192.168.5.1=Barnsley
  36:  
  37:'****** BRANCH OFFICE OPTIONS*******
  38: [London]
  39: SLShare=\\SCCMServer\OSDLOGS$\London\
  40: SitePrefix=LOND
  41: JoinDomain=London.local
  42: OSDDomainName=london
  43: OSDDomainOUName=OU=LONDON COMPUTERS,DC=LONDON,DC=LOCAL
  44:  
  45: [Manchester]
  46: SLShare=\\SCCMServer\OSDLOGS$\Manchester\
  47: SitePrefix=MANC
  48: JoinDomain=Manchester.local
  49: OSDDomainName=manchester
  50: OSDDomainOUName=OU=MANCHESTER COMPUTERS,DC=MANCHESTER,DC=LOCAL
  51:  
  52: [Newcastle]
  53: SLShare=\\SCCMServer\OSDLOGS$\Newcastle\
  54: SitePrefix=NEWC
  55: JoinDomain=Newcastle.local
  56: OSDDomainName=newcastle
  57: OSDDomainOUName=OU=NEWCASTLE COMPUTERS,DC=NEWCASTLE,DC=LOCAL
  58:  
  59: [Bristol]
  60: SLShare=\\SCCMServer\OSDLOGS$\Bristol\
  61: SitePrefix=BRIS
  62: JoinDomain=Bristol.local
  63: OSDDomainName=bristol
  64: OSDDomainOUName=OU=BRISTOL COMPUTERS,DC=BRISTOL,DC=LOCAL
  65:  
  66: [Barnsley]
  67: SLShare=\\SCCMServer\OSDLOGS$\Barnsley\
  68: SitePrefix=BARN
  69: JoinDomain=Barnsley.local
  70: OSDDomainName=barnsley
  71: OSDDomainOUName=OU=BARNSLEY COMPUTERS,DC=BARNSLEY,DC=LOCAL
  72:  
  73:  
  74: '****** DEFAULT OPTIONS******
  75: [Default]
  76: OSInstall=YES
  77: XResolution=1
  78: YResolution=1
  79: BitsPerPel=32
  80:  
  81:'****** TIMEZONE OPTIONS******
  82: TimeZone=085
  83: TimeZoneName=GMT Standard Time
  84: KeyboardLocale=en-GB
  85: UserLocale=en-GB
  86: UILanguage=en-US
  87: AreaCode=01332
  88: CountryCode=044
  89:  
  90: '****** GENERAL OPTIONS******
  91: DomainAdminDomain=%JoinDomain%
  92: DomainAdmin=administrator
  93: OSDNetworkJoinType=0
  94: OSDJoinAccount=%OSDDomainName%\administrator
  95: OSDDiskPart=YES
  96: OSDComputerName=%SitePrefix%-%ComputerTypeName%-%ComputerSerialNumber%
  97: _SMSTSOrgName= %OSDComputername% Coming Soon...
  98: AdminPassword=G4t3man
  99: OSDLocalAdminPassword=P@ssw0rd1
 100: DomainAdminPassword=P@ssw0rd2
 101: OSDJoinPassword=P@ssw0rd2


This assumes a couple of things.
1. You want the local admin account to be on and set to a singular password for each site, in the examples case this is set to P@ssw0rd1
2.  That you want the domain admin account to be used to add the computer to the domain and the domain admin account has the same password in each branch office, in the examples case this is P@ssw0rd2

Should you not want this (which I’d advise against) you can change this up as you see fit to match your own environments - Here I'm just testing the theory.  I’ll show you how later.  Lets break down the settings and try to make sense of them bit by bit.

   1: [Settings]
   2: Priority=GenerateSN, Am_I_a_VirtualMachine, Am_I_a_Desktop, Am_I_a_Laptop, DefaultGateway, Default
   3: Properties=SitePrefix, ComputerSerialNumber, ComputerTypeName

Here we are stating that the priority order in which the ‘settings’ get processed is denoted by what follows the ‘Priority’ section and that we are setting three properties which are named after the ‘Properties’ section.

   1: '******  WHOAMI OPTIONS******
   2: [GenerateSN]
   3: ComputerSerialNumber=#Right(Replace(Replace(oEnvironment.Item("SerialNumber")," ",""),"-",""),6)#
   4:  
   5: [Am_I_a_VirtualMachine]
   6: SubSection=VirtualMachine-%IsVM%
   7:  
   8: [Am_I_a_Desktop]
   9: SubSection=Desktop-%IsDesktop%
  10:  
  11: [Am_I_a_Laptop]
  12: SubSection=Laptop-%IsLaptop%
  13:  
  14: [VirtualMachine-True]
  15: ComputerTypeName=V
  16:  
  17: [Desktop-True]
  18: ComputerTypeName=D
  19:  
  20: [Laptop-True]
  21: ComputerTypeName=L

Here we are processing the building of the computer name.  The section “GenerateSN” reads the serial number from the computer.  The number denotes how many characters we want and the word “Right” means its taking them from the right inwards so reading left to right that would mean the last 6 digits.  You can change “Right” to “Left” and also the number, should you wish.  It also uses code to replace any dashes and spaces with nothing.  so 65-1234 would become 651234 before it is read into the setting.  (Cool huh!?).  The proceeding sections read the MDT variables and set accordingly.  If you have a desktop, the Am_I_a_Desktop setting becomes Desktop-True and the rest are set to false.  This results in the ComputerTypeName being set to a letter (either V, D or L)

Once we get this far we have processed the settings for GenerateSN, Am_I_a_VirtualMachine, Am_I_a_Desktop, and Am_I_a_Laptop with only DefaultGateway and Default settings left to process.

From this section we generate our “ComputerTypeName” and “ComputerSerialNumber” properties for the name of the computer we are deploying.  The rest of the settings I want to set based on gateway, so here I set up some gateways:

   1: '****** GATEWAY OPTIONS******
   2: [DefaultGateway]
   3: 192.168.1.1=London
   4: 192.168.2.1=Manchester
   5: 192.168.3.1=Newcastle
   6: 192.168.4.1=Bristol
   7: 192.168.5.1=Barnsley

Here we are saying if the default gateway is X process the settings labelled as X.  The first example states if the default gateway is 192.168.1.1 then run the settings for London.  The settings in “London” will be classed as our Gateway settings, so here we can set whatever we like that's going to be specific to the site.  In my case I set the following:

   1: '****** BRANCH OFFICE OPTIONS*******
   2: [London]
   3: SLShare=\\SCCMServer\OSDLOGS$\London\
   4: SitePrefix=LOND
   5: JoinDomain=London.local
   6: OSDDomainName=london
   7: OSDDomainOUName=OU=LONDON COMPUTERS,DC=LONDON,DC=LOCAL

1. Please put all logs for computers deployed at this site into the folder \\SCCMServer\OSDLOGS$\London\.  It will create a folder for each computer so you can trace the logs in case of errors.
2. Please set the SitePrefix property to “LOND”, which is the final property that builds up the computer name
3. Join the computer to london.local
4. Set the OU for the computer account on this domain to be LONDON.LOCAL> LONDON COMPUTERS

Sweet!

It is here you can set alternative security options.  For example if you wanted a different local admin password or domain join account password, they could be set here and built up per site/gateway you configure.  Hopefully as you study the settings we’ve set in this example you should understand how to build up your own custom ones.  If you aren't sure, feel free to ask and I’ll do my best to answer.  Follow me and DM me on Twitter and I’ll help you out, should you need it.

Before I move further, this is a basic example, but consider if you had distribution points in other countries.  At this point you could add any number of the MDT properties to set locale settings, keyboard layouts, time zones – all sorts of things relevant to your environments.  I think that’s pretty cool!  There are lots of MDT properties to explore take a look in the help section of deployment workbench to explore more.

Next we process Default options, which are the settings I want to process on every computer everywhere because they process for each OSD deployment. 

   1:'****** DEFAULT OPTIONS******
   2: [Default]
   3: OSInstall=YES
   4: XResolution=1
   5: YResolution=1
   6: BitsPerPel=32
   7:  
   8: '****** TIMEZONE OPTIONS******
   9: TimeZone=085
  10: TimeZoneName=GMT Standard Time
  11: KeyboardLocale=en-GB
  12: UserLocale=en-GB
  13: UILanguage=en-US
  14: AreaCode=01332
  15: CountryCode=044
  16:  
  17: '****** GENERAL OPTIONS******
  18: DomainAdminDomain=%JoinDomain%
  19: DomainAdmin=administrator
  20: OSDNetworkJoinType=0
  21: OSDJoinAccount=%OSDDomainName%\administrator
  22: OSDDiskPart=YES
  23: OSDComputerName=%SitePrefix%-%ComputerTypeName%-%ComputerSerialNumber%
  24: _SMSTSOrgName= %OSDComputername% Coming Soon...
  25: AdminPassword=G4t3man
  26: OSDLocalAdminPassword=P@ssw0rd1
  27: DomainAdminPassword=P@ssw0rd2
  28: OSDJoinPassword=P@ssw0rd2

OSDInstall = Yes and the strange resolution settings of 1 by 1 pixel is a trick I learned from Johan Arwidmark to trick the computer to use the recommended display settings after deployment.  It tricks the computer because 1 by 1 is an invalid resolution so during OSD the computer will assume the operator is drunk and will ignore your request and set it to the recommended resolution for the graphics card instead meaning you don’t have all your PC’s deploying with 1024x768 and then having to manually change them all.  Cheers Johan!

The Timezone settings are pretty straight forward, I’m setting things up for the UK here.  Adjust to suit.

The rest of the settings should hopefully make sense.  We are building up aspects of our settings bit by bit.  The OSDDomainName property set in our Gateway settings forms part of the account used to add the machine to the domain, in the case of london it would form LONDON\administrator. In the case of the computer name it builds it up using the properties set earlier and adds a hyphen in between each section.  A London Desktop computer example, therefore, would become LOND-D-123456 (where 123456 are the last 6 digits of the serial number).  This makes each computer unique! Just what we wanted.

Fleshing out the task sequence

Now that we can predict what the computer name format is going to look like for each subsequent OSD deployment, we can now flesh out our singular task sequence and deploy apps to certain sites by using WMI queries on the computer name. We know now, for example, that a computer in London will have a naming convention whereby the first four letters of the computer will be LOND.  Now we can add a sections in out task sequence that will only run if the computer name is prefixed with LOND.  Clever right?  This should give you a great foundation for creating the ‘One Task Sequence to rule them all!’ which is where I want my Zero Touch installations to go.

Gotchas

Don’t forget that this isn’t MDT so changes to customsettings.ini are not instant.  When you make a change, you must update the distribution points so that they process the change ready for the next test.

 

Well, I hope this has been useful for you.  I certainly enjoyed getting this set up and am now in a position where I’m fleshing out that all mighty task sequence to cover multiple sites.

Jonathan.

 

Reference:
https://deploymentbunny.com/2012/04/21/back-to-basic-customsettings-ini-explained/ - Mikael Nystroms page


Viewing all articles
Browse latest Browse all 6

Trending Articles