← Archive
article· jaw

Creating the ultimate SCCM 2007 Frontend HTA for OSD Part V

htaosdsccmtask-sequence

Here are all the files, just remember put the rules in with the MDT toolkit package.

Use theses files there are a couple of bug fixes from what is in the articles.

U-HTA.zip

 

***UPDATE****

 

Ok just a little post mortem update, found a couple of issues with the HTA log. It turns out that a task sequence will automatically delete the entire contents of the c: drive right before the apply operating system step thereby deleteing the log file created by the HTA at the beginning of the task sequence. I was able to solve this by simply storing the log information inside a task sequence variable during the deloyment and then writing it at the end of the task sequence. I already had the AD2.vbs script that was updating active directory with computer description so I moved the log writing code from the HTA into AD2.vbs.

-----------------NEW AD2.VBS script---------------------

If Wscript.Arguments.Count = 0 Then
 

Set WshNetwork = WScript.CreateObject("WScript.Network")
 Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
 
' get service tag and computer manufacturer
 For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
 serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
 manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
 Next
 
' get computer model
 For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
 model = trim(replace(objComputer.Model, ",", "."))
 Next
 

description = manufacturer & " " & model
log1 = "Log information has been lost somehow."
else
description =  Wscript.Arguments(0)
log1 = Wscript.Arguments(1)
end if
 
 

' get computer object in AD
 Set objSysInfo = CreateObject("ADSystemInfo")
 
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

' save into computer object
 objComputer.Description = description
 objComputer.SetInfo

 ' create log
 
Set objFSO=CreateObject("Scripting.FileSystemObject")
strFolder = "C:\Deployment-log"
 
if objFSO.FolderExists(strFolder) = False then
 objFSO.CreateFolder strFolder
 
end if
 
'Update log with deployment complete time
dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\Deployment-log\Workstation HTA.log", True)
 
log1 = log1 & vbcrlf & "Deployment Finish/ Déploiment complete" & now
filetxt.WriteLine(log1)
filetxt.Close

----------------------------end cut here --------------------------

Dealing with encrypted hard disks

One of the other issues that have been encoutered is that the task sequence will fail if the hard drive of a machine has been encrypted with securdoc or something similar. In order to avoid this problem I had to make a small modification to the Boot.wim file so that it will launch a script before getting to the SCCM stuff. It's fairly well documented how to do this but the basics are to mount the boot.wim and then add a TSconfig.INI and required files at the root. TSconfig will look something like this.

--------------------------------TSconfig.INI -------------------------------

[CustomHook]
Commandline="x:\encrypted.vbs"

-----------------------end cut----------------------------

to the root of the boot wim. It adds the custom hook to call our script.  We will also need the encrypted.vbs and cleandisk files.

-----------------------------------------------encrypted.vbs-------------------------------------------

' By: JAW
'
' This script is added to winPE it is called from the TSconfig.INI file and uses the cleandisk text file to
' pipe commands to diskpart.
' It attempts to detect if the drive in encrypted by checking to see if the c:\Documents and Settings and
' c:\RECYCLER as accessable (Win7 or XP) it also checks to see if there is a failed task sequence
' that has left a _SMSTasksequence folder on the drive. If any of theses conditions are true the a
' msgbox prompting to clean the drive will apear.

dim filesys, newfolder, oShell
set filesys=CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
crypt = true
 
if filesys.FolderExists("c:\_SMSTaskSequence ") Then
msg = "A task sequence in progress may have failed.  Do you wish to clean the drive?" & vbcrlf & "Votre séquence de tâches a échoué.  Désirez-vous néttoyer le disque dur?"
ret = msgbox (msg, 4, "Failed task sequence / Séquence de tâches échoué")
'6 = yes
 if ret = 6 then
 oShell.Run "diskpart.exe /s x:\cleandisk",,true
 clean = true
 end if
else

if clean = true then
crypt = false
end if

If filesys.FolderExists("c:\Documents and Settings")  Then

crypt = false
end if
If filesys.FolderExists("c:\RECYCLER")Then

crypt = false
end if

if crypt = true then
msg = "The drive appears to be encrypted or unpartitioned.  Do you wish to clean the drive?" & vbcrlf & "Le disque dur est enchiffré ou non patitionné.  Désirez-vous néttoyer le disque dur?"
ret = msgbox (msg, 4, "Encryption detected / Enchiffrage détecté")
'6 = yes
 if ret = 6 then  
 oShell.Run "diskpart.exe /s x:\cleandisk",,true
 end if
End If
end if

 

-----------------------end cut------------------------------------------------

-----------------------------clean disk file required by encrypted.vbs ------------

select disk 0
clean
exit

----------------end cut-------------------------------

 

Tags:

Restored from the original jawtech.com (archived copy). Links and downloads from that era may no longer work.