{"id":6157,"date":"2013-12-19T09:00:43","date_gmt":"2013-12-19T08:00:43","guid":{"rendered":"https:\/\/ingmarverheij.com\/?p=6157"},"modified":"2013-12-19T13:21:06","modified_gmt":"2013-12-19T12:21:06","slug":"mdt-select-operating-system-based-computer-name","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/mdt-select-operating-system-based-computer-name\/","title":{"rendered":"MDT: Select operating system based on computer name"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; float: right; display: inline; background-image: none;\" title=\"Windows Versions\" alt=\"Windows Versions\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Windows-Versions.jpg\" width=\"150\" height=\"94\" align=\"right\" border=\"0\" \/>By default a single operating system is linked to a task sequences in <a href=\"https:\/\/technet.microsoft.com\/en-US\/windows\/dn475741.aspx\" target=\"_blank\">Microsoft Deployment Toolkit<\/a> (MDT). This means that if you have different operating systems you need to built (and maintain) a task sequence for <strong>each<\/strong> operating system.<\/p>\n<p>A customer has different client types and wants to use a <strong>single task sequence <\/strong>to deploy <strong>different images<\/strong>. For this purpose a <strong>custom <\/strong>task is added that selects an operating system based on the <strong>prefix <\/strong>of the provided computer\u2019s name.<\/p>\n<p><!--more--><\/p>\n<h1>\u00a0<\/h1>\n<h1>Naming convention<\/h1>\n<p>The customer has a naming convention which uniquely identifies the different client types. Simply put, the first two characters determine the client type followed by a numerical identification number.<\/p>\n<blockquote>\n<p align=\"center\"><strong>AAnnnn<\/strong><\/p>\n<\/blockquote>\n<p>Where AA is the computer type and <em>nnnn <\/em>is the numerical identification number. The following computer types are available:<\/p>\n<table style=\"width: 247px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"137\"><strong>Computer name prefix<\/strong><\/td>\n<td valign=\"top\" width=\"108\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"137\">MC<\/td>\n<td valign=\"top\" width=\"108\">Medical clients<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"137\">NB<\/td>\n<td valign=\"top\" width=\"108\">Notebooks<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"137\">PC<\/td>\n<td valign=\"top\" width=\"108\">Workstations<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"137\">VC<\/td>\n<td valign=\"top\" width=\"108\">Vendor clients<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>Based on the naming convention the following machines could exist: MC1234, NB4321, PC1494, VC2598, etc.<\/em><\/p>\n<p>&nbsp;<\/p>\n<h1>Operating Systems<\/h1>\n<p>Besides unattended installations MDT can deploy <strong>images<\/strong> (injecting model specific drivers) captured from a reference machine. These images are stored as <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Imaging_Format\" target=\"_blank\">Windows Imaging Format<\/a> files (the same format that\u2019s used to boot and install Windows operating systems) and a referred to as <strong>Operating System<\/strong>.<\/p>\n<p>For <strong>each <\/strong>client type an image is captured and added to MDT as an operating system.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Deployment-Share-Operating-Systems.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Deployment Share - Operating Systems\" alt=\"Deployment Share - Operating Systems\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Deployment-Share-Operating-Systems_thumb.png\" width=\"554\" height=\"107\" border=\"0\" \/><\/a><\/p>\n<p>The name of the operating system in MDT is AA-BB where AA is the computer type and AA is the platform of the operating system (x86 or x64).<\/p>\n<p><em>Based on the naming convention the following operating systems could exist: MC-x86, MC-x64, PC-x86, PC-x64, etc.<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1>Task Sequence<\/h1>\n<p>Each task sequences has a reference to a <strong>single <\/strong>operating system, the base properties of this OS determine the how the task sequence is built-up (for instance which unattended.xml).<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-OS-Info.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Image Deploy x86 Properties - OS Info\" alt=\"Image Deploy x86 Properties - OS Info\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-OS-Info_thumb.png\" width=\"254\" height=\"228\" border=\"0\" \/><\/a><\/p>\n<p>The identifier of the OS is stored as <strong>OSGUID<\/strong> in the <strong>globalVarList<\/strong> in the <strong>ts.xml<\/strong> for for that task sequence.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Control-IMG-DEPLOY-x86-ts.xml_.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Control - IMG-DEPLOY-x86 - ts.xml\" alt=\"Control - IMG-DEPLOY-x86 - ts.xml\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Control-IMG-DEPLOY-x86-ts.xml_thumb.png\" width=\"554\" height=\"206\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h6>Install Operating System<\/h6>\n<p>The \u201cStandard Client Task Sqeuence&#8221;\u00a0 template contains a task <strong>Install Operating System<\/strong> which will install the operating system on the client. The operating system provided during the creation of the task sequence is stored at this task AND in the OS Info tab of the task sequence, I recommend choosing the <strong>default WIM <\/strong>file of the Windows <strong>installation <\/strong>your deploying, <strong>not <\/strong>a captured image.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-Install-Operating-System.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Image Deploy x86 Properties - Install Operating System\" alt=\"Image Deploy x86 Properties - Install Operating System\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-Install-Operating-System_thumb.png\" width=\"254\" height=\"228\" border=\"0\" \/><\/a><\/p>\n<h6>\u00a0<\/h6>\n<h6>Select OS based on OSD computer prefix<\/h6>\n<p>Right before the operating system is installed an operating system is selected based on the name of the computer. A <strong>Run Command Line<\/strong> task is added to execute a custom script:<\/p>\n<pre>cscript.exe \"%SCRIPTROOT%\\Z-CustomSelectOSBasedOnComputerPrefix.wsf\"<\/pre>\n<p>This script will determine the prefix of the computer name, the first two characters of the <strong>OSD Computer Name<\/strong>, and select the operating system whose name matches the prefix of the computer name + the operating system platform.<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-Select-OS-based-on-OSD-computer-prefix.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-width: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Image Deploy x86 Properties - Select OS based on OSD computer prefix\" alt=\"Image Deploy x86 Properties - Select OS based on OSD computer prefix\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Image-Deploy-x86-Properties-Select-OS-based-on-OSD-computer-prefix_thumb.png\" width=\"254\" height=\"228\" border=\"0\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1>Z-CustomSelectOSBasedOnComputerPrefix.wsf<\/h1>\n<p>The script that determines the OS to install, called from the task sequence, is relatively easy. It executes a number of tasks:<\/p>\n<ul>\n<li>Determines the name of the new computer (<strong>OSDComputerName<\/strong>)<\/li>\n<li>Stores the environment variable <strong>OSDComputerNamePrefix<\/strong> containing the <strong>prefix<\/strong> (first two characters) of the new computer name<\/li>\n<li>Iterates trough all operating systems in MDT. If the operating systems matches the criteria it will replace the <strong>OSGUID<\/strong> environment variable with the identified of the found operating system\n<ul>\n<li>The operating system must be <strong>Enabled<\/strong><\/li>\n<li>The <strong>platform<\/strong> of the operating system (x86 \/ x64) must match the platform of the task sequence<\/li>\n<li>The <strong>name<\/strong> of the operating system must match the prefix of the new computer name + the platform of the task sequence (eg. PC-x86 or NB-x64)<\/li>\n<\/ul>\n<\/li>\n<li>If no matching OS is found an empty GUID is returned, this will fail the installation (this is by wanted behaviour)<\/li>\n<\/ul>\n<h6>\u00a0<\/h6>\n<h6>Log<\/h6>\n<p>The script will log all output to Z-CustomSelectOSBasedOnComputerPrefix.log, (and BDD.log)\u00a0 this helps you troubleshoot the selection of an operating system.. <a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Z-CustomSelectOSBasedOnComputerPrefix.log_1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border: 0px currentColor; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;\" title=\"Z-CustomSelectOSBasedOnComputerPrefix.log\" alt=\"Z-CustomSelectOSBasedOnComputerPrefix.log\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2013\/12\/Z-CustomSelectOSBasedOnComputerPrefix.log_thumb1.png\" width=\"254\" height=\"126\" border=\"0\" \/><\/a><\/p>\n<h6>\u00a0<\/h6>\n<h6 id=\"Download\">Download<\/h6>\n<a  data-e-disable-page-transition=\"true\" class=\"download-link\" title=\"Version 1.1\" href=\"https:\/\/ingmarverheij.com\/en\/download\/6163\/?tmstv=1776499007\" rel=\"nofollow\" id=\"download-link-6163\" data-redirect=\"false\" >\n\tZ-CustomSelectOSBasedOnComputerPrefix.wsf<\/a>\n\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>.<\/p>","protected":false},"excerpt":{"rendered":"<p>By default a single operating system is linked to a task sequences in Microsoft Deployment Toolkit (MDT). This means that if you have different operating systems you need to built (and maintain) a task sequence for each operating system. A customer has different client types and wants to use a single task sequence to deploy [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[619],"tags":[675,631,226,627],"class_list":["post-6157","post","type-post","status-publish","format-standard","hentry","category-mdt","tag-mdt","tag-operating-system","tag-script","tag-task-sequence"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/6157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=6157"}],"version-history":[{"count":10,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/6157\/revisions"}],"predecessor-version":[{"id":6196,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/6157\/revisions\/6196"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=6157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=6157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=6157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}