Quantcast
Channel: MDT – The Deployment Bunny
Viewing all articles
Browse latest Browse all 70

Modifying the Lite Touch Wizard in MDT 2010 – Sample 2

$
0
0

This is the second part of a story around the MDT Wizard and the Wizard editor and the saga continues, but this time it’s going to be a bit more tricky since we need to add information to the wizard that does not exist by default in MDT. Last post was easy in the way that we just created a new page in the wizard that displays existing environment information, now the game has changed and my customer wants to have some hardware information, something like this:

image

The reason of having this page is to be sure that the machine has the correct hardware configuration, things like correct BIOS version, memory, CPU configuration but also to see that it has the Mac address that we “assume” it have. Also, we want to know if the model alias user exit script works correct and sets the correct model alias since we use that as a part of the driver group.

Now, most of the values can be collected directly from using Make, Model, Memory, Product, Architecture, AssetTag, SerialNumber, UUID, MacAddress. But for the rest we need to get them into the MDT environment somehow and the somehow in this case spells “UserExit”

UserExit is a way to extend MDT by writing some custom code (yes, that will be provided, hang on…), execute it and return the value into a custom property that can be used in rules or showed in the wizard page.

A user exit script is basically a VBscript with one or more functions and you can have them in one big userexit script or many, it is easier to have just one since that will be a bit cleaner and easier to manage. What we need is to get the name of the CPU, Hard drive, number of physical CPU’s and logical CPU’s and last but not least SMBiosversion. Well, I missed one, we also need to get the ModelAlias, but that user exit is already created by the deployment guys, so we just grab that and use it

But first of all, lets create the new Wizard page and here is how

Modifying the Wizard

Download the MDT Wizard editor from http://mdtwizardeditor.codeplex.com/

Fire it up and open the “DeployWiz_Definition_ENU.xml”. It is in the scripts folder (Make a backup of the file first). Then you add a new Wizard pane like this:

image

And then you add this HTML code into that page:


<h1>System information</h1>
<span style=”width: 95%;”>
<table border=”1″ cellspacing=”1″ cellpadding=”1″ width=”650″>
<tbody>
  <tr>
   <td width=”110″ align=”right”><em>Vendor</em></td>
   <td align=”left”><input style=”width: 220px” name=Make readonly></td>
   <td width=”110″ align=”right”><em>Model</em></td>
   <td align=”left”><input style=”width: 220px” name=Model readonly></td>
  </tr>
  <tr>
   <td width=”110″ align=”right”><em>Product</em></td>
   <td align=”left”><input style=”width: 220px” name=Product readonly></td>
   <td width=”110″ align=”right”><em>Memory(in Mb)</em></td>
   <td align=”left”><input style=”width: 220px” name=Memory readonly></td>
  </tr>
  <tr>
   <td width=”110″ align=”right”><em>CPU (in GHz)</em></td>
   <td align=”left”><input style=”width: 220px” name=processorspeed readonly></td>
   <td width=”110″ align=”right”><em>No: CPU\Cores</em></td>
   <td align=”left”><input style=”width: 108px” name=ComputerSystemNumberOfProcessors readonly>\<input style=”width:108px” name=ComputerSystemNumberOfLogicalProcessors readonly></td>
  </tr>
  <tr>
   <td width=”110″ align=”right”><em>Harddisk Info</em></td>
   <td align=”left”><input style=”width: 220px” name=DiskDriveCaptation readonly></td>
   <td width=”110″ align=”right”><em>Capable Architecture</em></td>
   <td align=”left”><input style=”width: 220px” name=”CapableArchitecture” readonly></td>
  </tr>
  <tr>
   <td width=”110″ align=”right”><em>Model Alias</em></td>
   <td align=”left”><input style=”width: 220px” name=MODELALIAS readonly></td>
   <td width=”110″ align=”right”><em>SMBIOSVERSION</em></td>
   <td align=”left”><input style=”width: 220px” name=SMBIOSVERSION readonly></td>
  </tr>

</tbody>
</table>

<table border=”1″ cellspacing=”1″ cellpadding=”1″ width=”650″>
<tbody>
      <tr>
         <td width=”150″ align=”right”><em>CPU</em></td>
        <td><input style=”width: 490px” name=CPUName readonly></td>
      </tr>
      <tr>
      <tr>
         <td width=”150″ align=”right”><em>Serial Number</em></td>
        <td><input style=”width: 490px” name=Serialnumber readonly></td>
      </tr>
      <tr>
         <td width=”150″ align=”right”><em>UUID</em></td>
        <td><input style=”width: 490px” name=UUID readonly></td>
      </tr>
      <tr>
         <td width=”150″ align=”right”><em>Mac Address</em></td>
        <td><input style=”width: 490px” name=MacAddress001 readonly></td>
      </tr>
      <tr>
         <td width=”150″ align=”right”><em>Assettag</em></td>
        <td><input style=”width: 490px” name=Assettag readonly></td>
      </tr>
</tbody>
</table>
</span>


You also need to a “condition” to the page so that you can turn it on or off based on rules and that should look like this:

image

To be sure that you get it correct, here is the code in plain text


Ucase(Property(“SkipHardwareInfo”)) <> “YES”


Modifying CustomSettings.ini

So, we are done with the Wizard, but if we run it now it will not really work, now it is time to modify CustomSettings.ini and that should look like this:

[Settings]
Priority=Init, ModelAliasInit, Default
Properties=MyCustomProperty, SkipHardwareInfo, ComputerSystemNumberOfProcessors, ComputerSystemNumberOfLogicalProcessors, ComputerSystemProductIdentifyingNumber, SMBIOSVersion, CPUName, DiskDriveCaptation, ModelAlias

[Init]
ComputerSystemNumberOfProcessors=#GetComputerSystemNumberOfProcessors()#
ComputerSystemNumberOfLogicalProcessors=#GetComputerSystemNumberOfLogicalProcessors()#
ComputerSystemProductIdentifyingNumber=#GetComputerSystemProductIdentifyingNumber()#
SMBIOSVersion=#GetBIOSSMBIOSVersion()#
CPUName=#GetCPUName()#
DiskDriveCaptation=#GetDiskDriveCaptation()#
UserExit=HardwareInfo.vbs

[ModelAliasInit]
ModelAlias=#SetModelAlias()#
UserExit=ModelAliasExit.vbs


Adding the scripts

We need two scripts, one called hardwareinfo.vbs and the other is ModelAlias.vbs, you can get ModelAlias from http://blogs.technet.com/b/deploymentguys/archive/2009/09/10/using-and-extending-model-aliases-for-hardware-specific-application-installation.aspx. The VBScript hardwareinfo.vbs however you will find here:


‘ //***************************************************************************
‘ // ***** Script Header *****
‘ //
‘ // Solution:  Custom Script for use with the Microsoft Deployment Toolkit
‘ // File:      hardwareinfo.vbs
‘ //
‘ // Purpose:   User exit script to get and set properties to be able to display the HardwareInfo Wizardpane.
‘ //           
‘ // Usage:     Modify CustomSettings.ini similar to this:
‘ //        [Settings]
‘ //        Priority=Init, Default
‘ //        Properties=MyCustomProperty, SkipHardwareInfo, ComputerSystemNumberOfProcessors, ComputerSystemNumberOfLogicalProcessors, ComputerSystemProductIdentifyingNumber, SMBIOSVersion, CPUName, DiskDriveCaptation, ModelAlias
‘ //
‘ //        [Init]
‘ //        ComputerSystemNumberOfProcessors=#SetComputerSystemNumberOfProcessors()#
‘ //        ComputerSystemNumberOfLogicalProcessors=#SetComputerSystemNumberOfLogicalProcessors()#
‘ //        ComputerSystemProductIdentifyingNumber=#SetComputerSystemProductIdentifyingNumber()#
‘ //        SMBIOSVersion=#SetBIOSSMBIOSVersion()#
‘ //        CPUName=#GetCPUName()#
‘ //        DiskDriveCaptation=#GetDiskDriveCaptation()#
‘ //
‘ // Version:   1.0
‘ // Author: Mikael Nystrom –
http://deploymentbunny.com
‘ //***************************************************************************

Function UserExit(sType, sWhen, sDetail, bSkip)
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs started: ” & sType & ” ” & sWhen & ” ” & sDetail, LogTypeInfo
    UserExit = Success
End Function

Function SetComputerSystemNumberOfProcessors()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting ComputerSystemNumberOfProcessors”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim NumberOfProcessors
    Dim ComputerSystemNumberOfProcessors

    Set objWMI = GetObject(“winmgmts:”)
    Set objResults = objWMI.InstancesOf(“Win32_ComputerSystem”)
        For each objInstance in objResults
            If Not IsNull(objInstance.NumberOfProcessors) Then
                NumberOfProcessors = Trim(objInstance.NumberOfProcessors)
            End If
        Next
            If NumberOfProcessors = “” Then
                NumberOfProcessors = “UNKNOWN”
            End If
    SetComputerSystemNumberOfProcessors = NumberOfProcessors
End Function

Function SetComputerSystemNumberOfLogicalProcessors()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting ComputerSystemNumberOfLogicalProcessors”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim NumberOfLogicalProcessors
   
    Set objWMI = GetObject(“winmgmts:”)
    Set objResults = objWMI.InstancesOf(“Win32_ComputerSystem”)
        If Err then
        oLogging.CreateEntry “Error querying Win32_ComputerSystem: ” & Err.Description & ” (” & Err.Number & “)”, LogTypeError
    Else
        For each objInstance in objResults
            If Not IsNull(objInstance.NumberOfLogicalProcessors) Then
                    NumberOfLogicalProcessors = Trim(objInstance.NumberOfLogicalProcessors)
            End If
        Next
    End If
    SetComputerSystemNumberOfLogicalProcessors = NumberOfLogicalProcessors
End Function

Function SetCPUName()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting CPUName”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim Name
    Dim CPUName
   
    Set objWMI = GetObject(“winmgmts:”)
    Set objResults = objWMI.ExecQuery(“SELECT * FROM Win32_Processor”)
        If Err then
        oLogging.CreateEntry “Error querying FROM Win32_Processor: ” & Err.Description & ” (” & Err.Number & “)”, LogTypeError
    Else
        For each objInstance in objResults
            If Not IsNull(objInstance.Name) Then
                    CPUName = Trim(objInstance.Name)
            End If
        Next
    End If
    SetCPUName = CPUName
End Function

Function SetBIOSSMBIOSVersion()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting BIOSSMBIOSVersion”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim SMBIOSBIOSVersion
   
    Set objWMI = GetObject(“winmgmts:”)
    Set objResults = objWMI.ExecQuery(“SELECT * FROM Win32_BIOS”)
        If Err then
        oLogging.CreateEntry “Error querying Win32_ComputerSystem: ” & Err.Description & ” (” & Err.Number & “)”, LogTypeError
    Else
        For each objInstance in objResults
            If Not IsNull(objInstance.SMBIOSBIOSVersion) Then
                    SMBIOSBIOSVersion = Trim(objInstance.SMBIOSBIOSVersion)
            End If
        Next
    End If
    SetBIOSSMBIOSVersion = SMBIOSBIOSVersion
End Function

Function SetDiskDriveCaptation()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting DiskDriveCaptation”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim Caption
   
    Set objWMI = GetObject(“winmgmts:”)
           Set objResults = objWMI.ExecQuery(“SELECT * FROM Win32_DiskDrive where mediatype like ‘Fixed%hard disk%’”)
        If Err then
        oLogging.CreateEntry “Error querying Win32_DiskDrive: ” & Err.Description & ” (” & Err.Number & “)”, LogTypeError
    Else
        For each objInstance in objResults
            If Not IsNull(objInstance.Caption) Then
                    Caption = Trim(objInstance.Caption)
            End If
        Next
    End If
    SetDiskDriveCaptation = Caption
End Function

Function SetComputerSystemProductIdentifyingNumber()
    oLogging.CreateEntry “UserExit:HardwareInfo.vbs – Getting ComputerSystemProductIdentifyingNumber”, LogTypeInfo
    Dim objWMI
    Dim objResults
    Dim objInstance
    Dim IdentifyingNumber
    Dim ComputerSystemProductIdentifyingNumber
    Set objWMI = GetObject(“winmgmts:”)
    Set objResults = objWMI.InstancesOf(“Win32_ComputerSystemProduct”)
        For each objInstance in objResults
            If Not IsNull(objInstance.IdentifyingNumber) Then
                IdentifyingNumber = Trim(objInstance.IdentifyingNumber)
            End If
        Next
            If IdentifyingNumber = “” Then
                IdentifyingNumber = “UNKNOWN”
            End If               
    SetComputerSystemProductIdentifyingNumber = IdentifyingNumber
End Function


Wrapping up

So, now you have a new Wizard pane that will give you some more information from the computer before you install the machine and if you don’t like to see that page the only thing you need to do is to add SkipHardwareInfo=YES in Customsettings.ini

/mike



Viewing all articles
Browse latest Browse all 70

Trending Articles