Before you start relying on this sample, I'd like to say that: If you still uses MBSA 1.2.1 and this script would help you keep your automation, I strongly encourage you to upgrade your scripts to support MBSA 2.0. MBSA 2.0 provides more data, in a more structured and organized format, making the parsing easier, more precise and more robust. Now let's get to the sample...
Usage: cscript /nologo mbsa2lr.vbs <your-report-file> Example: cscript /nologo mbsa2lr.vbs "%USERPROFILE%\SecurityScans\REDMOND - NELSONA (7-25-2005 2-53 PM).mbsa"
Usage: cscript /nologo mbsa2lr.vbs <your-report-file>
Example: cscript /nologo mbsa2lr.vbs "%USERPROFILE%\SecurityScans\REDMOND - NELSONA (7-25-2005 2-53 PM).mbsa"
File: MBSA2LR.XSL - Rules to convert the report
<?xml version="1.0"?><!--mbsa2text.xsl - Converts the missing updates into text-delimited formatRequires: MBSA 2.0Author: Nelson AraujoDownload: http://blogs.msdn.com/nelson_araujo/archive/2005/07/29/mbsa_automation_sample2.aspx Copyright (C) 2005 Microsoft Corporation. All rights reserved.Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This example assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requients. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at 1-800-936-5200. For more information about Microsoft Certified Partners, see the following Microsoft Web site:http://directory.microsoft.com/resourcedirectory/Solutions.aspx For additional information about the support options available from Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;[LN];CNTACTMS--><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:variable name="CR" select="''"/><xsl:variable name="TAB" select="' | '"/><xsl:template match="/">Machine Name<xsl:value-of select="$TAB"/>Product<xsl:value-of select="$TAB"/>Bulletin<xsl:value-of select="$TAB"/>Q Number<xsl:value-of select="$TAB"/>Reason<xsl:value-of select="$TAB"/>Status<xsl:apply-templates select="//UpdateData"/></xsl:template><xsl:template match="UpdateData"><xsl:value-of select="../../../@DisplayName"/><xsl:value-of select="$TAB"/><xsl:value-of select="../../@GroupName"/> <xsl:value-of select="$TAB"/><xsl:value-of select="@BulletinID"/><xsl:value-of select="$TAB"/><xsl:value-of select="@KBID"/><xsl:value-of select="$TAB"/><xsl:text>N/A</xsl:text><xsl:value-of select="$TAB"/><xsl:if test="@IsInstalled = 'true'"><xsl:text>Installed</xsl:text> </xsl:if><xsl:if test="@IsInstalled = 'false'"><xsl:text>Missing</xsl:text></xsl:if><xsl:value-of select="$CR"/></xsl:template></xsl:stylesheet>
File: MBSA2LR.VBS - XSL rules processor '------------------------------------------------------------------------------'' mbsa2text.vbs - Converts the missing updates into text-delimited format' Requires: MBSA 2.0' Author: Nelson Araujo' Download: http://blogs.msdn.com/nelson_araujo/archive/2005/07/29/mbsa_automation_sample2.aspx '' Copyright (C) 2005 Microsoft Corporation. All rights reserved.'' Microsoft provides programming examples for illustration only, without ' warranty either expressed or implied, including, but not limited to, the ' implied warranties of merchantability or fitness for a particular purpose. ' This example assumes that you are familiar with the programming language ' that is being demonstrated and the tools that are used to create and debug ' procedures. Microsoft support professionals can help explain the ' functionality of a particular procedure, but they will not modify these ' examples to provide added functionality or construct procedures to meet your ' specific requirements. If you have limited programming experience, you may ' want to contact a Microsoft Certified Partner or the Microsoft fee-based ' consulting line at 1-800-936-5200. For more information about Microsoft ' Certified Partners, see the following Microsoft Web site:' ' http://directory.microsoft.com/resourcedirectory/Solutions.aspx '' For additional information about the support options available from ' Microsoft, visit the following Microsoft Web site:' ' http://support.microsoft.com/default.aspx?scid=fh;[LN];CNTACTMS ''------------------------------------------------------------------------------Option ExplicitDim xmlDim xslDim outputSet xsl = CreateObject("MSXML2.DOMDocument")Set xml = CreateObject("MSXML2.DOMDocument")If Not xsl.load("mbsa2lr.xsl") Then WScript.Echo "Cannot load XSL file" WScript.Quit(2)End IfIf Not xml.load(WScript.Arguments(0)) Then WScript.Echo "Cannot load MBSA report file" WScript.Quit(3)End If' Process the reportWScript.Echo xml.transformNode(xsl) Sample output:
File: MBSA2LR.VBS - XSL rules processor
'------------------------------------------------------------------------------'' mbsa2text.vbs - Converts the missing updates into text-delimited format' Requires: MBSA 2.0' Author: Nelson Araujo' Download: http://blogs.msdn.com/nelson_araujo/archive/2005/07/29/mbsa_automation_sample2.aspx '' Copyright (C) 2005 Microsoft Corporation. All rights reserved.'' Microsoft provides programming examples for illustration only, without ' warranty either expressed or implied, including, but not limited to, the ' implied warranties of merchantability or fitness for a particular purpose. ' This example assumes that you are familiar with the programming language ' that is being demonstrated and the tools that are used to create and debug ' procedures. Microsoft support professionals can help explain the ' functionality of a particular procedure, but they will not modify these ' examples to provide added functionality or construct procedures to meet your ' specific requirements. If you have limited programming experience, you may ' want to contact a Microsoft Certified Partner or the Microsoft fee-based ' consulting line at 1-800-936-5200. For more information about Microsoft ' Certified Partners, see the following Microsoft Web site:' ' http://directory.microsoft.com/resourcedirectory/Solutions.aspx '' For additional information about the support options available from ' Microsoft, visit the following Microsoft Web site:' ' http://support.microsoft.com/default.aspx?scid=fh;[LN];CNTACTMS ''------------------------------------------------------------------------------Option ExplicitDim xmlDim xslDim outputSet xsl = CreateObject("MSXML2.DOMDocument")Set xml = CreateObject("MSXML2.DOMDocument")If Not xsl.load("mbsa2lr.xsl") Then WScript.Echo "Cannot load XSL file" WScript.Quit(2)End IfIf Not xml.load(WScript.Arguments(0)) Then WScript.Echo "Cannot load MBSA report file" WScript.Quit(3)End If' Process the reportWScript.Echo xml.transformNode(xsl)
<?xml version="1.0" encoding="UTF-16"?>Machine Name | Product | Bulletin | Q Number | Reason | StatusREDMOND\NELSONA | Office | | 842774 | N/A | InstalledREDMOND\NELSONA | Office | | 842532 | N/A | InstalledREDMOND\NELSONA | Office | | 840663 | N/A | InstalledREDMOND\NELSONA | Office | MS05-023 | 887979 | N/A | InstalledREDMOND\NELSONA | Windows | | 867460 | N/A | InstalledREDMOND\NELSONA | Windows | MS04-043 | 873339 | N/A | InstalledREDMOND\NELSONA | Windows | MS04-041 | 885836 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-001 | 890175 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-004 | 886903 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-007 | 888302 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-009 | 887472 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-013 | 891781 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-015 | 888113 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-012 | 873333 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-016 | 893086 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-018 | 890859 | N/A | InstalledREDMOND\NELSONA | Windows | MS04-044 | 885835 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-011 | 885250 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-026 | 896358 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-032 | 890046 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-027 | 896422 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-033 | 896428 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-025 | 883939 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-019 | 893066 | N/A | InstalledREDMOND\NELSONA | Windows | | 890830 | N/A | InstalledREDMOND\NELSONA | Windows | MS05-037 | 903235 | N/A | InstalledREDMOND\NELSONA | Windows | | 890830 | N/A | MissingREDMOND\NELSONA | Windows | MS05-036 | 901214 | N/A | Installed