I needed a really simple script/solution to make sure that only tested/certified Computer models are being installed so I created this simple little script for it.
- It will prompt the user that the computer model isn’t supported
- Logs the make/model to a log file on a share
- Fail the task sequence
To keep it simple I use the same query as in the task sequence to deploy driver packages to sort out if the Computer model is supported by the task sequence. So you can simply copy the query from the Apply driver package step.
Then I use ServiceUI.exe from MDT 2012 together with a vbscript to prompt the user that the Computer model isn’t supported and write to a log file. ServiceUI.exe is simply brilliant as you can interact with the user from a Task Sequence! Fantastic!
The Show Dialog step looks like this:
The log file will contain the following information
Here is the VBscript, simply change the path to the log file and create the log file as well, the script will not create the log file if it doesn’t exits.
To implement it:
- Create the group as described above in the Task Sequence
- Create the WMI conditions
- Download MDT 2012 to obtain ServiceUI.exe
- Download the dialog.vbs file and rename it to Dialog.vbs
- Change the path to the log file(make sure everyone has permissions to the share)
- Create the text file used as log file.
- Create a package in ConfigMgr (no program necessary) with the two files ServiceUI.exe and Showdialog.vbs in the source directory.
- Create a step to show the dialog, run it from the package created.
The script can also be downloaded here Dialog.vbs
'Script to prompt the user that the computermodel is not supported and fail the task sequence
'ccmexec.com
'log file to be used
strFile = "\\sccm02.demiranda.nu\pkgsource$\log\model.txt"
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
strManufacturer = objItem.Manufacturer
strModel = objItem.Model
Next
Set TsProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
TsProgressUI.CloseProgressDialog
'Write log file
Const ForAppending = 8
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(strFile, ForAppending, True)
objFile.WriteLine("Time Stamp: " & Now & " Manufacturer = "& strManufacturer & " Model = "& strmodel)
objFile.Close
MsgBox "This Computer model is not supported, the installation will be aborted." & chr(13) & "Please contact servicedesk for assistance", 16,"Installation aborted!"
wscript.quit(1)
Hi Jorgen,
Whats in your SetSMSTSErrorDialogTimeout Step?
Hi,
good point!
I set the SMSTSErrorDialogTimeOut to a low value so that the Task sequence error message doesn’t stay up that long after the dialog that the computer is not certified.
Regards,
Jörgen
nice post Jorgen,
one thing to note, you need to use the version of serviceUI.exe with the same architecture as the boot image that you are deploying with, so if you are using say a X64 boot image, then you must use the serviceUI.exe (same name, you can rename it to serviceUIx64.exe to have both in the same package) from C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64) otherwise the task sequence will fail with an error in SMSTS.log saying “The subsystem needed to support the image type is not present. Error: 80070134”.
cheers
niall.
Thanks Niall, good point I will update the post, I always use the x86 boot image, but all that is going to change as well, specially with UEFI.
Very useful post Jörgen
Thanks!