![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 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 Specs![]() |
| | #4 (permalink) |
| | 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 - what you are doing there in more detail. PeterCS |
My System Specs![]() |
![]() |
| 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 | |||