Freigeben über


Using and Extending Model Aliases for Hardware Specific Application Installation

Update 11 December 2009 – A few changes and additions inspired by the work being done by fellow MSC Senior Consultant Steven Markegene.  Of note are the changes to the Hyper-V model strings and a new one added by Steven.  The script download has been updated as well.

In a post on his blog from a few years ago (found here) Ben Hunter described a method of creating and using model aliases using BDD/MDT User Exit scripts.  A model alias is a friendly name assigned to cover multiple model variations in a manufacturer’s computer model family.  I have been going through this exercise for my current customer and have found some limitations to using Ben’s process exactly as is.

First, the MDT properties Make and Model (which come from the Manufacturer and Model properties of the Win32_ComputerSystem WMI class) are no longer sufficient or necessarily the most convenient properties for determining the model alias.  For example, distinguishing between Microsoft’s different types of virtual machines (Virtual PC, Virtual Server, Hyper-V) requires looking at Version property of the Win32_BIOS WMI class.  Also, many current Lenovo computer models already have the Version property of the Win32_ComputerSystemProduct WMI class filled in with a friendly name for the model.  Here is a sample of a User Exit script with an expanded SetModelAlias function that uses this additional information. (Note that some lines may wrap on the screen depending on your display resolution.)

Function UserExit(sType, sWhen, sDetail, bSkip)

    oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs started: " & sType & " " & sWhen & " " & sDetail, LogTypeInfo

    UserExit = Success

End Function

Function SetModelAlias()

    oLogging.CreateEntry "------------ Initialization USEREXIT:ModelAliasExit.vbs|SetModelAlias -------------", LogTypeInfo

    sMake = oEnvironment.Item("Make")
sModel = oEnvironment.Item("Model")
SetModelAlias = ""
sCSPVersion = ""
sBIOSVersion = ""

    Set colComputerSystemProduct = objWMI.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
If Err then
oLogging.CreateEntry "Error querying Win32_ComputerSystemProduct: " & Err.Description & " (" & Err.Number & ")", LogTypeError
Else
For Each objComputerSystemProduct in colComputerSystemProduct
If not IsNull(objComputerSystemProduct.Version) then
sCSPVersion = Trim(objComputerSystemProduct.Version)
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Win32_ComputerSystemProduct Version: " & sCSPVersion, LogTypeInfo
End If
Next
End if

    Set colBIOS = objWMI.ExecQuery("SELECT * FROM Win32_BIOS")
If Err then
oLogging.CreateEntry "Error querying Win32_BIOS: " & Err.Description & " (" & Err.Number & ")", LogTypeError
Else
For Each objBIOS in colBIOS
If not IsNull(objBIOS.Version) then
sBIOSVersion = Trim(objBIOS.Version)
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Win32_BIOS Version: " & sBIOSVersion, LogTypeInfo
End If
Next
End if

    ' Check by Make
Select Case sMake

        Case "Dell Computer Corporation", "Dell Inc.", "Dell Computer Corp."

            ' Use Model with spaces removed
SetModelAlias = Replace(sModel, " ", "")

        Case "IBM", "LENOVO"

            ' Check by Version property of the Win32_ComputerSystemProduct WMI class first
If Not sCSPVersion = "" Then
Select Case sCSPVersion
Case "ThinkPad T61p"
SetModelAlias = "ThinkPadT61"
Case Else
' Use Version with spaces removed
SetModelAlias = Replace(sCSPVersion, " ", "")
End Select
End If

            ' Check by first 4 characters of the Model

            If SetModelAlias = "" Then
sModelSubString = Left(sModel,4)
Select Case sModelSubString
Case "1706"
SetModelAlias = "ThinkPadX60"
Case Else
SetModelAlias = sModel
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Alias rule not found. ModelAlias set to Model value." , LogTypeInfo
End Select

            End If

        Case "Matsushita Electric Industrial Co.,Ltd."

            'Panasonic Toughbook models
If Left(sModel,2) = "CF" Then
SetModelAlias = Left(sModel,5)
Else
SetModelAlias = sModel
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Alias rule not found. ModelAlias set to Model value." , LogTypeInfo
End If

        Case "Microsoft Corporation"

            Select Case sBIOSVersion
Case "VRTUAL - 1000831"
SetModelAlias = "Hyper-V2008BetaorRC0"
Case "VRTUAL - 5000805", "BIOS Date: 05/05/08 20:35:56 Ver: 08.00.02"
SetModelAlias = "Hyper-V2008RTM"
Case "VRTUAL - 3000919"
SetModelAlias = "Hyper-V2008R2"
Case "A M I - 2000622"
SetModelAlias = "VS2005R2SP1orVPC2007"
Case "A M I - 9000520"
SetModelAlias = "VS2005R2"
Case "A M I - 9000816", "A M I - 6000901"
SetModelAlias = "WindowsVirtualPC"
Case "A M I - 8000314"
SetModelAlias = "VS2005orVPC2004"
Case Else
SetModelAlias = sModel
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Alias rule not found. ModelAlias set to Model value." , LogTypeInfo
End Select

        Case "VMware, Inc."

            SetModelAlias = "VMware"

        Case Else
If Instr(sModel, "(") > 2 Then
SetModelAlias = Trim(Left(sModel, Instr(sModel, "(") - 2))
Else
SetModelAlias = sModel
oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - Alias rule not found. ModelAlias set to Model value." , LogTypeInfo
End if

    End Select

    oLogging.CreateEntry "USEREXIT:ModelAliasExit.vbs|SetModelAlias - ModelAlias has been set to " & SetModelAlias, LogTypeInfo

    oLogging.CreateEntry "------------ Departing USEREXIT:ModelAliasExit.vbs|SetModelAlias -------------", LogTypeInfo

End Function

Second, even a model alias is insufficient to identify which hardware specific applications should be installed during a deployment.  At minimum, you usually also need to know the operating system version and architecture for which the applications are targeted.  For example, for a Lenovo T61 you would typically have one hardware specific application list for Windows XP x86, one list for Windows Vista x86, one list for Windows Vista x64, etc.  To that end I created a new composite property called ModelOSArchAlias. which combines the ModelAlias, OSVersion, and Architecture properties.  (I refer to this property by a newly minted acronym called MOAA.  Catchy, isn’t it. J )  I create this by using CustomSettings.ini entries like the ones below:

[Settings]
Priority=SetModelAlias, Default
Properties=MyCustomProperty, ModelAlias, ModelOSArchAlias

[SetModelAlias]
UserExit=ModelAliasExit.vbs
ModelAlias=#SetModelAlias()#
ModelOSArchAlias=%ModelAlias%_%OSVersion%_%Architecture%

So for a Lenovo ThinkPad X60 running 32-bit Windows Vista using my SetModelAlias function and this CustomSettings.ini, the MOAA would be ThinkPadX60_Vista_X86.

To define settings, applications, roles, etc. in the MDT Database based on either the ModelAlias or ModelOSArchAlias, enter the ModelAlias or ModelOSArchAlias as the Model in the Make and Model entries in the Database.  You can put anything you want in the the Make field in the database entries.  I enter the alias type (ModelAlias or ModelOSArchAlias) so that I can sort the entries by type.  Here is a screen shot with a ModelAlias and ModelOSArchAlias entry for the Panasonic Toughbook model CF-U1 that I have been working with recently.  (Ignore the DeviceAlias and DeviceOSArchAlias entries.  I’ll describe those in my next post.  J )

Model-DeviceAlias

You would then use CustomSettings.ini entries like the ones below.  (The DatabaseVariables section below is there because I like to use variables for the common database parameters in the other sections so that the actual values only have to be changed in the DatabaseVariables section.  Note that some lines may wrap on the screen depending on your display resolution.)

[Settings]
Priority=SetModelAlias, DatabaseVariables, MASettings, MAPackages, MAApps, MAAdmins, MARoles, MOAASettings, MOAAPackages, MOAAApps, MOAAAdmins, MOAARoles
Properties=MyCustomProperty, MASQLServer, MADatabase, MANetlib, MASQLShare, ModelAlias, ModelOSArchAlias

[SetModelAlias]
UserExit=ModelAliasExit.vbs
ModelAlias=#SetModelAlias()#
ModelOSArchAlias=%ModelAlias%_%OSVersion%_%Architecture%

[DatabaseVariables]
MASQLServer=SQLS001
MADatabase=MDT
MANetlib=DBNMPNTW
MASQLShare=Logs$

[MASettings]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelSettings
Parameters=ModelAlias
ModelAlias=Model

[MAPackages]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelPackages
Parameters=ModelAlias
ModelAlias=Model
Order=Sequence

[MAApps]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelApplications
Parameters=ModelAlias
ModelAlias=Model
Order=Sequence

[MAAdmins]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelAdministrators
Parameters=ModelAlias
ModelAlias=Model

[MARoles]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelRoles
Parameters=ModelAlias
ModelAlias=Model

[MOAASettings]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelSettings
Parameters=ModelOSArchAlias
ModelOSArchAlias=Model

[MOAAPackages]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelPackages
Parameters=ModelOSArchAlias
ModelOSArchAlias=Model
Order=Sequence

[MOAAApps]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelApplications
Parameters=ModelOSArchAlias
ModelOSArchAlias=Model
Order=Sequence

[MOAAAdmins]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelAdministrators
Parameters=ModelOSArchAlias
ModelOSArchAlias=Model

[MOAARoles]
SQLServer=%MASQLServer%
Database=%MADatabase%
Netlib=%MANetlib%
SQLShare=%MASQLShare%
Table=MakeModelRoles
Parameters=ModelOSArchAlias
ModelOSArchAlias=Model

When to set the MOAA and execute MOAA Database Queries

In a computer replacement and/or OS change (different source and destination OS) scenario you will likely only want the technique shown above for creating the ModelOSArchAlias and do the MOAA database queries using a Gather step in the State Restore phase.  This is because you will almost always want to hardware specific settings, application installations, etc. based on the target model and operating system.  You cannot create the ModelOsArchAlias as shown above during the WinPE phases since the OS and architecture found will be that of WinPE.  However, you could generate the equivalent if necessary.

Since most task sequences are only installing a single OS/architecture (e.g. Win7 x64), you could add a Set Task Sequence variable step to “hard code” the OS and architecture part of ModelOsArchAlias. For example:

ModelOSArchAlias=%ModelAlias%_Win7Client_X64

If you are installing more than single OS/architecture in your task sequence, you could use a User Exit script, CustomSettings.ini rules, or MDT database entries to set custom properties like TargetOSVersion and TargetArchitecture based the OS/architecture to be applied.  You would then set ModelOsArchAlias like this:

ModelOSArchAlias=%ModelAlias%_%TargetOSVersion%_%TargetArchitecture%

For example, fellow MSC Senior Consultant Steven Markegene is working with his customer to deploy both Windows 7 x86 and Windows 7 x64 from a single task sequence.  In his case, they are using a custom MDT database Settings table field for TargetArchitecture.  In the MDT database Computer Settings node they are setting TargetArchitecture to either X86 or X64 for each computer.  He is setting TargetOSVersion equal to Win7Client as a Set Task Sequence Variable step to run before the Gather step and using the above line to set ModelOsArchAlias in the SetModelAlias section of CustomSettings.ini.  For this to work, the CSettings section must be listed before the SetModelAlias section in the Priority line in CustomSettings.ini.

For the OS and architecture strings in either case, use the values that ZTIGather.wsf would generate (i.e. the sOSVersion values in GetOSVersion and sArchitecture values in GetAssetInfo in ZTIGather.wsf).

 

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

This post was contributed by Michael Murgolo, a Senior Consultant with Microsoft Services - U.S. East Region.

ModelAliasExit.zip

Comments

  • Anonymous
    January 01, 2003
    This is the second part of a story around the MDT Wizard and the Wizard editor and the saga continues

  • Anonymous
    January 01, 2003
    There are occasions where the variables I needed to use to query or retrieve data from the database were

  • Anonymous
    January 01, 2003
    There are occasions where the variables I needed to use to query or retrieve data from the database were

  • Anonymous
    January 01, 2003
    Bill, Where did you obtain v1.0.4?  The version available for download with this post is still v1.0.3.  I do have a private version 1.0.4 that I have not put on the blog yet but the only changes to the VMware section. Michael Murgolo

  • Anonymous
    January 01, 2003
    There are occasions where the variables I needed to use to query or retrieve data from the database were

  • Anonymous
    January 24, 2011
    Thanks for the info. What is the easiest way to get the values of sMake, sModel, SetModelAlias, sCSPVersion and sBIOSVersion value on the screen (on all different models with Windows 7) so that I can reference them on the MDT Task Sequences? Thanks,

  • Anonymous
    January 02, 2013
    Curious why did you change the Lenovo Aliasing in the 1.0.4 revision to just reflect the Lenovo 7 charater part number.  The 1.0.3 version I had been using did what I consider proper and spit out the friendly model name as the alias.. ex ThinkpadT400

  • Anonymous
    May 11, 2014
    The comment has been removed

  • Anonymous
    May 12, 2014
    Pingback from Material de apoyo usado en la preconferencia de TechED NA 2014 (deployment??s) + links de interes – Freelance-IT Ags, Mex.

  • Anonymous
    May 13, 2014
    The comment has been removed

  • Anonymous
    November 21, 2014
    The OSVersion variable is populated with a short string representing the version of the operating system