Friday, May 23, 2008
This is a nice and short talk on the emergence of open source information, not just software, and how it is reshaping economies.  Even though everyone is pretty well used to the internet, at least in rich industrial nations, we are still in the very early stages of its development.  It's only been commercially available for 15 years.  There are some great ideas in this talk about where it might go and how it may impact industry.

Friday, May 23, 2008 1:14:05 AM (Central Standard Time, UTC-06:00)
 Wednesday, May 21, 2008

I just found this great new blog for efficient and power concious living.  Check it out.

http://www.metaefficient.com/

Wednesday, May 21, 2008 12:11:02 PM (Central Standard Time, UTC-06:00)
 Wednesday, May 14, 2008

So I've recently had the task of fetching some information out of system.nfo files to translate cryptic IDs numbers into human readable friendly names.  This is the thing that XML is supposed to excel at right?  Well you would think that task would be simple enough, and as it turns out it is.  However searching for this solution online proved to be difficult, so I'm going to retell my experience here in hopes that it might help anyone else with this problem out.

I started with what I thought was a nice elegant powershell script that would query the XML like a SQL DB and return my value.  Seems simple enough right?

$friendlyName = $sysinfo.MsInfo.Category.Category.Category.Data.DeviceName | where {$sysinfo.MsInfo.Category.Category.Category.Data.Device_ID -eq $global:deviceName}

 

This would work with normal XML where your content is inside the XML tags.  However the system.nfo file uses CDATA objects and many nests of categories so you have to go one step further.  Since I don't know which Category sub-tree my offending device or data might be in, I ended up grabbing all of the data objects that met my criteria and doing a breadth first search.  Sounds ugly compared to the one liner up there, but it actually works and don't take that long.  The following code is in powershell.  The key here is that handy get_innertext() method.  Your standard .Value or .Text won't cut it with CDATA.

# Open the associated .nfo file
$sysinfo_file = $global:computer_name + ".nfo"
$sysinfo_path = $global:computer_name + "\" + $sysinfo_file
[xml]$sysinfo = get-content $sysinfo_path
 
$nodeList1 = @($sysinfo.GetElementsByTagName("Device_Name"))
$nodeList2 = @($sysinfo.GetElementsByTagName("Device_ID"))
$nodeList3 = @($sysinfo.GetElementsByTagName("Manufacturer"))
 
$i = 0
foreach($node in $nodeList2)
{
    $deviceID = $nodeList2[$i].get_innertext()
    if($deviceID -eq $global:device_name)
    {
        $friendlyName = $nodeList1[$i].get_innertext()
        $deviceManuf = $nodeList3[$i].get_innertext()
    }
    $i++
}

The purpose of this handy little script is to look up a cryptic device ID and return a friendly manufacturers name.

Wednesday, May 14, 2008 11:20:06 AM (Central Standard Time, UTC-06:00)