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
'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
Set TsProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
'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)
MsgBox "This Computer model is not supported, the installation will be aborted." & chr(13) & "Please contact servicedesk for assistance", 16,"Installation aborted!"