Set Role During OSD (based on PC Name) and then Install Applications RRS feed

  • Question

  • Hi,

    I have defined three roles in the MDT DB - StaffLaptop, PupilLaptop and ExamLaptop.  I then have a script that runs during the OSD Pre-Install phase that reads the OSDComputerName variable and then sets the Role variable to be one of the three roles.

    The script is very simple, it gets the left three characters of the OSDComputerName variable, if it begins SL- the role is set to StaffLaptop, PL- = PupilLaptop and EL- = Exam Laptop.

    I use oEnvironment.Item("Role") = "StaffLaptop" to set the variable value.  I have also tried "Role001" and "Role1" as variable names.

    In all cases the variable is set (if I read the variables.dat file in MiniNT), however no applications are installed on the computer during OSD PostInstall.  Other applications however that are assigned, based on model for example, are successfully installed.

    At the end deployment the Task Sequence completes successfully and the MiniNT folder is cleaned up before I can view the log files to confirm if the role based applications were selected.  One application is the Cisco Any Connect client (exe) and the other a bat file that runs to copy necessary configuration files for Any Connect to the default user profile.

    Am I missing something obvious?



    Friday, August 21, 2015 5:26 PM

All replies

  • Add the SLShare property to customsettings so your deployment logs are saved.


    Once you can save the logs, you can look through them to see what's going on with your variable.

    If this post is helpful please vote it as Helpful or click Mark for answer.

    Friday, August 21, 2015 8:12 PM
  • Are you planning to assign these roles to anything like a Computer or Locations entry in the MDT Database?. That is how you use Roles. Here is an example -

    Having said that, I think we can easily achieve what you want in CustomSettings.ini and do not need a script. Here is what I had in mind:







    • Edited by SanjoySaha Saturday, August 22, 2015 1:04 AM
    Saturday, August 22, 2015 12:50 AM
  • Thanks - I have added the logging path and have now been able to view the log files.

    It looks like the applications that are part of the role are being selected correctly however another application is giving an erroneous return code during it's installation.

    The log reports the "Toshiba Value Added Package" gives a return code of -3:

    Application TOSHIBA Sat Pro L850 - Value Added Package returned an unexpected return code: -3 ZTIApplications 24/08/2015 10:34:23 0 (0x0000)

    Immediately after this it then starts installing The AnyConnect client however this fails because another installation is in progress:

    Application Cisco Systems Any Connect Web Client 3.1.10010 returned an unexpected return code: 1618 ZTIApplications 24/08/2015 10:34:28 0 (0x0000)

    I've tried having a search for a return code of -3 but not finding much of use.  Does anyone know what this might be?  The Toshiba VAP is an MSI app but you launch it via an exe using /s for silent.  I have done this for a couple of years with other models and have never had any issues before.  Additionally other laptops that use another version of VAP are imaging correctly.



    Monday, August 24, 2015 11:48 AM
  • Thanks Sanjoy.

    I was hoping to stick with the GUI method of adding applications to the role as this makes it simpler for other technicians to use that aren't as happy with editing the INI file.

    It looks like my solution is now working (after adding another gather step to the TS after setting the role), however, if you see my reply to @Dan_Vega it looks like i'm now encountering an issue with an unexpected return code from a separate mandatory app.

    Monday, August 24, 2015 11:50 AM
  • Can you manually run the msiexec command from a command prompt and check if the msi is getting installed. If it is still failing can you collect the log file ? -

    Sorry just saw that the app is launched as exe. Do you have any logs associated with the application if you run it from a command line? Also any errors in the Application logs? If not you can enable Windows Installer Logging and share the log with us -

    • Edited by SanjoySaha Monday, August 24, 2015 1:06 PM
    Monday, August 24, 2015 12:59 PM
  • Here's a script I use to install apps and create a log. Just rename that parts of it that you need to customize it for your needs. For example rename all instances of "Install-APPLICATION" to "Install-ToshibaL850". Once you run your task sequence and when this application tries to install, it'll create it's own log file called Install-ToshibaL850.log and you should hopefully be able to find more details in that log.

    <job id="Install-APPLICATION">
    <script language="VBScript" src="..\..\scripts\ZTIUtility.vbs"/>
    <script language="VBScript">
    ' //***************************************************************************
    ' // Purpose: Template with error logging
    ' // Usage: cscript.exe Install-APPLICATION.wsf [/debug:true]
    ' // Creator: Daniel Vega
    ' // Version: 1.0 - 1/26/2015
    ' // Notes:
    ' //
    ' //***************************************************************************
    '// Global constant and variable declarations
    Option Explicit
    Dim iRetVal
    '// End declarations
    '// Main routine
    On Error Resume Next
    iRetVal = ZTIProcess
    ProcessResults iRetVal
    On Error Goto 0
    '// Function: ZTIProcess()
    '// Input: None
    '// Return: Success - 0
    '// Failure - non-zero
    '// Purpose: Perform main ZTI processing
    Function ZTIProcess()
    	Dim sSetupFile
    	Dim sArguments
    	sSetupFile = oUtility.ScriptDir & "\Source\APPLICATION.MSI"
    	sArguments = "/switches"
    	' Disable Zone Checks
    	'Install APPLICATION
    	oLogging.CreateEntry oUtility.ScriptName & ": Starting installation", LogTypeInfo
    	If not oFSO.FileExists(sSetupFile) then
    		oLogging.CreateEntry oUtility.ScriptName & ": " & sSetupFile & " was not found, unable to install", LogTypeError
    		ZTIProcess = Failure
    		Exit Function
    	End if
    	iRetVal = oUtility.RunWithHeartbeat("msiexec.exe /i """ & sSetupFile & """ " & sArguments & " /l*v """ & oUtility.LocalRootPath & "\SMSOSD\OSDLOGS\Install-APPLICATION.log""")
    	if (iRetVal = 0) or (iRetVal = 3010) then
    		ZTIProcess = Success 
    		ZTIProcess = Failure
    		oLogging.CreateEntry "Install-APPLICATION: Error installing Application. Check the log " & oUtility.LocalRootPath & "\SMSOSD\OSDLOGS\Install-APPLICATION.log", LogTypeWarning
    	End If
    	' Enable Zone Checks
    	oLogging.CreateEntry oUtility.ScriptName & ": Return code from command = " & iRetVal, LogTypeInfo
    	oLogging.CreateEntry oUtility.ScriptName & ": Finished installation", LogTypeInfo
    End Function

    If this post is helpful please vote it as Helpful or click Mark for answer.

    Monday, August 24, 2015 1:15 PM