Windows Vista Forums

Add-Member not Adding a member
  1. #1


    PeterCS Guest

    Add-Member not Adding a member

    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

      My System SpecsSystem Spec

  2. #2


    Arnoud Jansveld Guest

    RE: Add-Member not Adding a member

    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
    >

      My System SpecsSystem Spec

  3. #3


    PeterCS Guest

    Re: Add-Member not Adding a member

    On Nov 26, 11:44*am, Arnoud Jansveld
    <ArnoudJansv...@xxxxxx> wrote:

    > 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- Hide quoted text -
    >
    > - Show quoted text -
    I figured that would be the next option just creating a custom object.
    I just thought there would be something more elegant. Is it the XML
    import that is hurting my ability to do add-memeber?

    PeterCS

      My System SpecsSystem Spec

  4. #4


    PeterCS Guest

    Re: Add-Member not Adding a member

    On Nov 26, 11:44*am, Arnoud Jansveld
    <ArnoudJansv...@xxxxxx> wrote:

    > 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- Hide quoted text -
    >
    > - Show quoted text -
    Thanks alots this works like a charm. I will now have look up exactly
    what you are doing there in more detail.

    PeterCS

      My System SpecsSystem Spec

Add-Member not Adding a member problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
SBS + Member Servers DCHOBO SBS Server 3 06 Aug 2009
New member Berniepc General Discussion 3 01 Aug 2008
Get-member Swamy Channaveera PowerShell 9 10 Apr 2008
Adding domain member to local admin group New ACT user Vista account administration 2 03 Feb 2007