Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Add-Member not Adding a member

Reply
 
Old 11-26-2008   #1 (permalink)
PeterCS


 
 

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
Old 11-26-2008   #2 (permalink)
Arnoud Jansveld


 
 

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:
Quote:

> 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
Old 11-26-2008   #3 (permalink)
PeterCS


 
 

Re: Add-Member not Adding a member

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

> 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:
Quote:

> > 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.
>
Quote:

> > Here is an example input file I am reading. Call it dell.xml
>
Quote:

> > <?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>
>
Quote:

> > Here is the script I am trying to make work with it.
>
Quote:

> > 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
>
Quote:

> > 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.
>
Quote:

> > What am i doing wrong here?
>
Quote:

> > 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
Old 11-26-2008   #4 (permalink)
PeterCS


 
 

Re: Add-Member not Adding a member

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

> 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:
Quote:

> > 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.
>
Quote:

> > Here is an example input file I am reading. Call it dell.xml
>
Quote:

> > <?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>
>
Quote:

> > Here is the script I am trying to make work with it.
>
Quote:

> > 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
>
Quote:

> > 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.
>
Quote:

> > What am i doing wrong here?
>
Quote:

> > 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
Reply

Thread Tools


Similar Threads
Thread Forum
Why does add-member not work? PowerShell
New member General Discussion
Get-member PowerShell
Adding domain member to local admin group Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46