Monday, September 2, 2013

Step 1.1: Full OS Validation

This is the first step of the All-in-One task sequence. This step initiates only when it is run in Full OS mode, in other words when initiated by an end user.
Key points are;
-          The task sequence will check the associated conditions and executed only if it is launched in Full         OS Mode
-          Will NOT execute if launched in WinPE or OEMMedia

In Full OS Validation step:
-          We will copy few files to local drive of the machine
-          Task Sequence will launch few scripts based on the conditions. These scripts will create a flag  
       files on the target machine.
-          Based on the flag file existence, we will create a Task Sequence custom variables
-          If a condition is true for supported model, HTA will prompt with a warning msg and with a password prompt. After validating the password the TS continues or user can cancel.
Following Group conditions should be met before executing Full OS Validation;
                 Task Sequence variable true  _SMSTSLaunchMode equals SMS
               Task Sequence variable true  _SMSTSMediaType  notequals OEMMedia
Create Package called FullOSValidationHTA using Migration.hta file (sample code provided below), ServiceUIx32.exe and ServiceUIx64.exe
Copy HTA step copies the FullOSValidationHTA package source files to C:\Migration folder.

Create a package called FullOSDMigration using Unsupported.hta and Supported.cmd (Both sample sourced provided below). We will be adding more files to this package later.
Copy OSD++ step copies the FulISDMigration package contents to existing C:\Migration folder.

Model validation step will be executed if the conditions are met.
For example if the condition is TRUE for SELECT * FROM Win32_ComputerSystem WHERE Model LIKE '%VMware Virtual Platform%' then this step will execute and launch Supported.cmd file from C:\Migration, which was copied in previous step. That cmd file will write Supported.txt file to C:\Migration.
Sample Supported.cmd file:
**********************************************************
@echo off
REM Supported.cmd
echo Supported model detected>>C:\Migration\Supported.txt
**********************************************************
Based on the existence of the Supported.txt file, we will create custom Task Sequence variables.
Supported Model TS Variable step will be executed based on the TRUE condition of existence of Supported.txt in C:\Migration and created a custom Task Sequence variable win7supported value TRUE
 
 
Unsupported Model TS Variable step will be executed based on the None TRUE condition of existence of Supported.txt in C:\Migration and created a custom Task Sequence variable Win7Supported value FALSE
 Now, we can use above created custom task sequence variables to launch the supported and unsupported HTA files to generate MSG windows to the end users.
MSG for Supported models HTA file will be launched if the task Sequence variable for Win7Supported  equals TRUE then will display a HTA file as below;

The HTA file will validate the password, before continuing with the upgrade. If user cancels the upgrade, the HTA file will create a UserCancelled.txt file under C:\Migration folder then exists the Task Sequence gracefully. The UserCancelled.txt file will be used to create a custom Task Sequence variable.
Sample Migration.HTA file;
**************************************************************************
<html>
 <head>
 <title>For Venu Singireddy's Blog</title>
 <HTA:APPLICATION
     ID="OSD"
     APPLICATIONNAME="Operating System Deployment HTA"
      SCROLL="Yes"
      SINGLEINSTANCE="yes"
       BORDER="thick"
       SysMenu="no"
 >
 </head>
<SCRIPT LANGUAGE="VBScript">
On Error Resume Next
     Set TSProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
     TSProgressUI.CloseProgressDialog
    Sub Window_Onload
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
       Next
       intLeft = (intHorizontal - 800) / 2
        intTop = (intVertical - 600) / 2
        window.resizeTo 800,515
        window.moveTo intLeft, intTop
    End Sub
  Sub OSDSub
  set WshShell = CreateObject("WScript.Shell")
  Set objFSO = CreateObject("Scripting.FileSystemObject")
 if PasswordArea.value = "password" Then
  Msgbox "Thanks password is correct. Task sequence will now Continue"
  Set objFile = objFSO.CreateTextFile("C:\Migration\Migration.txt")
  Self.Close 
  Else
  Msgbox "Sorry, password is not correct. Please try again", 64, "Wrong Password"
  End If
    End Sub
Sub Reboot
Dim objWshShell
Set objWshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\Migration\UserCancelled.txt")
' objWshShell.Run ("shutdown.exe /r /f /t 60 /c ""You have canceled Operating system migration. The system will re-start in 60 seconds. Please save any open files and close any running applications."" /d p:0:1"), 0, False
window.Close
End Sub
</SCRIPT>
<body>
 <body bgColor="E6DDDD">
 <style type='text/css'>
p{font-family:Calibri; font-size:12pt;}
p{font-family:Calibri; font-size:12pt;}
h1{font-family:Calibri; font-size:large;}
h4{font-family:Calibri; font-size:medium; color:Red}
</style>
 <h1 align="Center">Venu Singireddy's Blog</h1>
 <h1 align="Center">  <font color="GREEN">ATTENTION</h1> </font>
 <h4 align="Center">Windows 7 Operating System Deployment</h4>
  <P>Your PC has been nominated for Operating System upgrade to Windows 7. </p>  
   <p> <Strong>Before you proceed with Operating System upgrade, Please make sure - <br>
    &nbsp;&nbsp;&nbsp; - Backup your data from local hard drive <br>
     &nbsp;&nbsp;&nbsp; - If you have any external USB / Pen drives attached to the computer, disconnect them  </strong><br> </p> 
     <p> Once you are ready for the upgrade, enter the password provided by Service Desk then click Continue with the upgrade box below.     
     <p>If you are not ready to upgrade your Operating System to Windows 7 or If you need any help with the upgrade, Please click on Cancel the Upgrade and contact the Service Desk </p>
     <input type="password" style="width:100px" name="PasswordArea" size="30"><P>
     <input id=runbutton style="height: 30px" class="button" type="button" value="Continue with the Upgrade" name="run_button"  onClick="OSDSub">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 <input id=runbutton style="height: 30px" type="button" value="Cancel the Upgrade" onClick="Reboot" align="left" color="red">
</body>
**************************************************************************
If task Sequence variable for Win7Supported  notequals TRUE then MSG for unsupported models will be launched and will displayed the following MSG;

Sample unsupported.hta file:
**************************************************************************
<html>
 <head>
 <title>OS Deployment - Model Not supported</title>



 <HTA:APPLICATION
     ID="objTest"
     APPLICATIONNAME="Operating System Deployment HTA"
      SCROLL="no"
      SINGLEINSTANCE="yes"
   BORDER="thick"
   SysMenu="no"
 >
 </head>

<SCRIPT LANGUAGE="VBScript">
On Error Resume Next
 Set TSProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
 TSProgressUI.CloseProgressDialog
    Sub Window_Onload
        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
        For Each objItem in colItems
            intHorizontal = objItem.ScreenWidth
            intVertical = objItem.ScreenHeight
        Next
        intLeft = (intHorizontal - 600) / 2
        intTop = (intVertical - 400) / 2
        window.resizeTo 500,350
        window.moveTo intLeft, intTop
    End Sub

 
Sub Reboot
Dim objWshShell
Set objWshShell = CreateObject("WScript.Shell")
' objWshShell.Run ("shutdown.exe /r /f /t 60 /c ""You have cancelled Operating system migration. The system will re-start in 60 seconds. Please save any open files and close any running applications."" /d p:0:1"), 0, False
window.Close
End Sub


</SCRIPT>

<body>
 <body bgColor="E6DDDD">

 <style type='text/css'>
p{font-family:Calibri; font-size:12pt;}
h1{font-family:Calibri; font-size:large;}
h4{font-family:Calibri; font-size:medium; color:Green}
</style>


  <h1 align="Center">Venu Singireddy's blog</h1>
  <h4 align="Center">Windows 7 Operating System Deployment</h4>
  <P>Your PC model is not supported to migrate to new Windows 7 operating system. </p>
  
  <p> The upgrade process will now terminate. </p>
  <p>If you need further information, Please contact help desk. <br>

   </P>
   
     
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
 
  <input id=runbutton style="height: 25px; width: 70px" type="button" value="Exit" onClick="Reboot" align="left" color="red">

</body>
******************************************************************************

The Task Sequence will exit gracefully when user Exit’s the build process by clicking Exit button.
Set user Cancelled TS Variable will be initiated when C:\Migration\UserCancelled.txt exits.
User Cancelled Task Sequence variable will be used to exit the Task Sequence gracefully when the user selects to cancel the Task Sequence.
Summary:
Full OS validation step is the first step for All-in-one task sequence. This step will be launched ONLY when the Task Sequence is advertised to a collection and launched in full OS. This step is mainly useful for Migration / Refresh scenarios.
 
Click here for complete list of tasks for SCCM OSD All in one task sequence.
Click here for SCCM OSD All in one task sequence Visio diagram.



4 comments:

  1. Could you provide the rest of the information for MSG for Supported/Unsupported models and the Set user Cancelled TS Variable? This is a great bit of information and it is assisting my steps greatly while I learn how to make my own HTA files. Thank you for the time you have put into this and I hope to see the information soon!

    ReplyDelete
  2. You mention the Unsupported.HTA and show what it looks like but you forgot to include the code for it.

    ReplyDelete
  3. Anonymous thank you for the feedback
    I have updated the post with the code.
    Modify as needed.

    Regards,
    Venu S

    ReplyDelete
  4. Hello, I am guessing the "MSG for Unsupported Models" is simply a run command line of "C:\Migration\Migration.hta"? Correct?

    The same is true for the "MSG for Supported Models" only it is executing "C:\Migration\Migration.hta"?

    ReplyDelete