SCCM Deployment - Generating MIF file using VBScript

The below VBScript will create the package installation status MIF file. The problem with the script initiated deployment is that it returns the success status even if the action performed by the script failed.


 
I have found this script on appdeploy website. The original script is located at http://www.appdeploy.com/messageboards/tm.asp?m=52414  

 
Script Usage: SMSWriteStatusMIF “MIF File Name”, “Manufacturer”, “Product Name”, “Version”, “Description”,bSuccess

 
MIF File Name   : Name of the status MIF file.
Manufacturer      : The application vendor
Product Name     : Application name
Version               : Application version
Description         : The error description
bSuccess             : True / False

Script
 
Sub SMSWriteStatusMIF(FileName,Manufacturer, Product, Version, Description, bSuccess)
' Writing a status MIF for SWDist to return a success or a failure to execute
' Product is the name of the Script and MIF file.
' Description is the status message
' bSuccess is True/False of success

 
Const ForWriting = 2
Dim mifFile
Dim WinpDir

 
Set FileSys = CreateObject("Scripting.FileSystemObject")
WinDir = oShell.ExpandEnvironmentStrings("%WINDIR%")
Set mifFile = FileSys.CreateTextFile(WinDir & "\" & FileName , ForWriting)

 
With mifFile
.Writeline ("START COMPONENT")
.Writeline ("NAME = ""WORKSTATION""")
.Writeline (" START GROUP")
.Writeline (" NAME = ""ComponentID""")
.Writeline (" ID = 1")
.Writeline (" CLASS = ""DMTF|ComponentID|1.0""")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Manufacturer""")
.Writeline (" ID = 1")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Manufacturer & """")
.Writeline (" END ATTRIBUTE")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Product""")
.Writeline (" ID = 2")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Product & """")
.Writeline (" END ATTRIBUTE")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Version""")
.Writeline (" ID = 3")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = """ & Version & """")
.Writeline (" END ATTRIBUTE")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Locale""")
.Writeline (" ID = 4")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(16)")
.Writeline (" VALUE = ""ENU""")
.Writeline (" END ATTRIBUTE")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Serial Number""")
.Writeline (" ID = 5")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = ""NIL""")
.Writeline (" END ATTRIBUTE")

 
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Installation""")
.Writeline (" ID = 6")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(64)")
.Writeline (" VALUE = ""DateTime""")
.Writeline (" END ATTRIBUTE")
.Writeline (" END GROUP")

 
.Writeline (" START GROUP")
.Writeline (" NAME = ""InstallStatus""")
.Writeline (" ID = 2")
.Writeline (" CLASS = ""MICROSOFT|JOBSTATUS|1.0""")
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Status""")
.Writeline (" ID = 1")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(32)")

 
' Pass or fail this status mif?
If bSuccess = true then
.Writeline (" VALUE = ""Success""")
else
.Writeline (" VALUE = ""Failed""")
End if

 
.Writeline (" END ATTRIBUTE")
.Writeline (" START ATTRIBUTE")
.Writeline (" NAME = ""Description""")
.Writeline (" ID = 2")
.Writeline (" ACCESS = READ-ONLY")
.Writeline (" STORAGE = SPECIFIC")
.Writeline (" TYPE = STRING(256)")
.Writeline (" VALUE = """ & Description & """")
.Writeline (" END ATTRIBUTE")
.Writeline (" END GROUP")
.Writeline ("END COMPONENT")
End With

 
mifFile.Close
Set mifFile = Nothing
End Sub
Package Properties


Ensure that you have made the below changes so that Configuration Manager client pick the correct status MIF file.

• In the Reporting tab of package properties, select “Use package properties for status MIF matching”. This is the default option.
Alternatively you can also select “Use these fields for status MIF matching” option. In case of second option you need to provide the MIF file name. Other fields can be ignored. The MIF file name should be same as generate by script.

• In the General tab of package properties, enter the package name, version and manufacturer. Ensure that you are using the same name in the script.

Comments

Post a Comment

Popular posts from this blog

SCCM Software Distribution Troubleshooting

Powershell - List AD Organizational Unit and GPOs linked to them

Troubleshooting System Center Endpoint Protection (SCEP) Client