Hi Peter,
If it is not important to keep the XML structure I would suggest the
following (mind the wrapping):
[string]$Name = $xml.ComparisonReport.System.hostname
[string]$Model = $xml.ComparisonReport.System.model
$final = $xml.ComparisonReport.Comparison | select
@{name='Computer';exp={$Name}}, @{name='ModelType';exp={$Model}}, *
Regards,
Arnoud
--
http://www.jansveld.net/powershell
"PeterCS" wrote:
> I am sure my logic is wrong here but I am working on a script that
> just does something very simple. The script reads a XML file provided
> from a Dell firmware utility and then creates a report on screen at
> this point. My issue lies in the way I am trying to add information
> into the object below.
>
> Here is an example input file I am reading. Call it dell.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ComparisonReport>
> <System Model="PE2650" HostName="SERVERNAME"/>
> <Comparison PackageName="PE2650_BIOS_WIN_A21" ComponentName="BIOS"
> ComponentType="BIOS" CurrentVersion="A21" RepositoryVersion="A21"
> Criticality="Inapplicable" State="Equal"/>
> <Comparison PackageName="RAID-DRVR-R74084" ComponentName="Dell PERC
> 3/Di RAID Controller Driver" ComponentType="Driver"
> CurrentVersion="2.8.0.6085" RepositoryVersion="2.8.0.6085"
> Criticality="Inapplicable" State="Equal"/>
> <Comparison PackageName="ESM-WIN-A02" ComponentName="Embedded System
> Management Controller" ComponentType="Firmware" CurrentVersion="A02"
> RepositoryVersion="A02" Criticality="Inapplicable" State="Equal"/>
> <Comparison PackageName="RAID_FRMW_WIN_R168380" ComponentName="Dell
> PERC 3/Di RAID Controller Firmware" ComponentType="Firmware"
> CurrentVersion="2.8.1.7692" RepositoryVersion="2.8.1.7692"
> Criticality="Inapplicable" State="Equal"/>
> <Comparison PackageName="NIC_DRVR_WIN_R196228"
> ComponentName="Broadcom NetXtreme I and NetXtreme II Driver Family"
> ComponentType="Driver" CurrentVersion="12.4.0"
> RepositoryVersion="12.4.0" Criticality="Inapplicable" State="Equal"/>
> <Comparison PackageName="OM_5.5.0_ManNode_A00"
> ComponentName="OpenManage Server Administrator" ComponentType="APP"
> CurrentVersion="5.5.0" RepositoryVersion="5.5.0"
> Criticality="Inapplicable" State="Equal"/>
> </ComparisonReport>
>
> Here is the script I am trying to make work with it.
>
> write-host "`nDell Update Utility This script assumes access to the
> XML file under current credentials`n" -for red -bac black
> $i = read-host "Enter the path to the Dell Update Utility Export File
> (xml)"
> $xml = [xml] (gc $i)
> $Name = $xml.ComparisonReport.System.hostname | out-string
> $Model = $xml.ComparisonReport.System.model | out-string
> $final = $xml.ComparisonReport.Comparison
> Foreach ($f in $final)
> {
> write-host $f
> Add-Member -InputObject $f -membertype noteproperty -name Computer -
> value $Name
> Add-member -InputObject $f -membertype noteproperty -name ModelType -
> value $Model
> }
> $final
>
> I could just display the $final and be done with it but my ultimate
> goal is for this to loop through a directory of similar XML file for
> 200 + servers and get a report so i would like to have a Name of the
> server and model number for sorting ablities.
>
> What am i doing wrong here?
>
> Peter
>