Tuesday, January 31, 2012

Powershell XML XPATH search example (Dell SUU)

Over the last few years, I have taken a few shots at using powershell's XML features to do some automating of the Dell SUU update system.  In the past, I had some vaguely working prototypes that worked on one system and didn't work on another.  After taking another look at it, I discovered the use of Xpath to help match up available updates for a system.  In the SUU CD/DVD sets, you will find a Catalog.xml file in the Repository folder.  This file contains SoftwareComponents and SoftwareBundle branches.  The Bundle nodes are collections of OS + Device Model information to provide a full list of all updates.  The SoftwareComponents get into the individual updates themselves + OS + SupportedDevices.  Using Dell's WMI extensions (installed with OMSA 4.? and higher); namespace: root\CIMV2\Dell and class Dell_CMDevice to get information about the on board devices.  Each entry in this Class has a deviceID, vendorID, subDeviceID and subVendorID which can be used as an XPath search in the catalog file for the latest update for that component.

Here's an example of getting started with this:

$catalog = [xml](get-content c:\temp\suu\repository\catalog.xml)
$devices = Get-wmiobject -namespace "root\cimv2\dell" -class Dell_cmdevice
$mydevice = $devices[0]
$xpathstr = "//SoftwareComponent[@packageType='LWXP']/SupportedDevices/Device/PCIInfo"
$xpathstr += "[@deviceID=`'" + $mydevice.deviceID + "`' and @vendorID=`'" + $mydevice.vendorID +"`' and @subDeviceID=`'" + $mydevice.subDeviceID + "`' and @subVendorID=`'" + $mydevice.subvendorID + "`']/../../.."
select-xml $catalog -xpath $xpathstr |select-object -expandproperty Node

This will give you something like this:

schemaVersion        : 1.0
packageID              : R222914
releaseID                : R222914
hashMD5                : 6944D638979E5CE651234D216AFDC3C7
path                         : RAC_FRMW_WIN_R222914.EXE
dateTime                  : 2009-06-30T14:33:14-05:00
releaseDate              : June 30, 2009
vendorVersion          : 1.75
dellVersion               : A01
packageType           : LWXP
Name                      : Name
ComponentType      : ComponentType
Description              : Description
LUCategory            : LUCategory
Category                 : Category
SupportedDevices   : SupportedDevices
ImportantInfo           : ImportantInfo
Criticality                 : Criticality

As you can see, the device that is being check is a RAC card.  This is the latest update package for it.  You can use other classes in the Dell WMI namespace to pull the current version details of your devices to compare it to what is available in the SUU repository.  This part its a bit hackish though as you need to look at Dell_CMDeviceApplication and pull data out of the middle of strings, or combine Dell_CMDeviceApplication with Dell_CMApplication class results to get an easier version number.  The Dell_CMDeviceApplication class seems to just bridge between two different classes giving data like this:

Antecedent       : //Server/root/cimv2/dell:Dell_CMDevice.componentID="
                   ",name="Dell Remote Access Controller 4/I",vendorID="1028",d
                   eviceID="0012",subDeviceID="0012",subVendorID="1028",bus="",
                   device="",function=""
Dependent        : //Server/root/cimv2/dell:Dell_CMApplication.componen
                   tType="FRMW",subComponentID="",version="1.35",name="Dell Rem
                   ote Access Controller 4/I Firmware",deviceKey=":Dell Remote
                   Access Controller 4/I:1028:0012:0012:1028:::"

In the future, I will pull this together a bit more and try to provide a working SUU check for all devices on a Dell system along with update options.  Update: Solution sample

1 comment:

  1. Making good progress with this:

    Component : FlashBIOS Updates
    path : PE2850_BIOS_WIN_A07.EXE
    vendorVersion : A07
    releaseDate : May 23, 2008
    Criticality : Optional
    currentversion : A05
    AtCurrent : False

    Component : Embedded Server Management
    path : BMC_FRMW_WIN_R223079.EXE
    vendorVersion : 1.83
    releaseDate : June 30, 2009
    Criticality : Optional
    currentversion : 1.52
    AtCurrent : False

    Component : Embedded Server Management
    path : ESM_FRMW_WIN_R99806.EXE
    vendorVersion : 1.00
    releaseDate : June 21, 2005
    Criticality : Recommended
    currentversion : 1.00
    AtCurrent : True

    Component : SCSI Raid
    path : RAID_DRVR_WIN_R99970.EXE
    vendorVersion : 6.46.2.32
    releaseDate : June 07, 2005
    Criticality : Recommended
    currentversion : 6.46.2.32
    AtCurrent : True

    Component : Network Drivers
    path : NIC_DRVR_WIN_R94800.EXE
    vendorVersion : 8.4.21.0
    releaseDate : March 28, 2005
    Criticality : Recommended
    currentversion : 8.4.21.0
    AtCurrent : True

    Component : Network Drivers
    path : NIC_DRVR_WIN_R94800.EXE
    vendorVersion : 8.4.21.0
    releaseDate : March 28, 2005
    Criticality : Recommended
    currentversion : 8.4.21.0
    AtCurrent : True

    Component : SCSI Raid
    path : RAID_FRMW_WIN_R186634.EXE
    vendorVersion : 5B2D
    releaseDate : October 07, 2008
    Criticality : Urgent
    currentversion : 522A
    AtCurrent : False

    ReplyDelete