Get-Dellwarranty - Multiple entries tied to single service tag

Welcome Forums General PowerShell Q&A Get-Dellwarranty - Multiple entries tied to single service tag

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 month, 2 weeks ago.

  • Author
    Posts
  • #169342

    Participant
    Topics: 1
    Replies: 1
    Points: 2
    Rank: Member

    Greetings Powershell peers, first time post here.

    Goal : Use this Get-DellWarranty script to "get" warranty information, export to csv, then manipulate via excel to generate reports. My servieTags.csv contains the fields computername, serial

    $computers = import-csv .\serviceTags.csv
    $data1 = $computers | select name, @{name='serial'; exp={ForEach-Object -Process{(Get-DellWarranty -ServiceTag $PSItem.serial).serial}}},
    @{name='model'; exp={ForEach-Object -Process{(Get-DellWarranty -ServiceTag $PSItem.serial).model}}},
    @{name='Enddate'; exp={ForEach-Object -Process{(Get-DellWarranty -ServiceTag $PSItem.serial).enddate -as [datetime]}}},
    @{name='startdate'; exp={ForEach-Object -Process{(Get-DellWarranty -ServiceTag $PSItem.serial).startdate -as [datetime] }}}
    || Export-ToCsv .\DellWarranty.csv
    
    

    And here is the resulting output exported to csv

    Name serial model Enddate startdate
    comp1 G81BRP2 Precision 5820 Tower 6/8/2021 23:59 6/9/2018 0:00
    comp2 G817RP2 Precision 5820 Tower 6/8/2021 23:59 6/9/2018 0:00
    comp3 G824RP2 Precision 5820 Tower 6/8/2021 23:59 6/9/2018 0:00
    comp4 4MLYZ12 4MLYZ12 OptiPlex 3020 OptiPlex 3020
    comp5 4RPYZ12 4RPYZ12 4RPYZ12 OptiPlex 3020 OptiPlex 3020 OptiPlex 3020
    comp6 4MCVZ12 4MCVZ12 OptiPlex 3020 OptiPlex 3020

    Issue : As can be seen from table above, some serial numbers return multiple "serial" objects and return an empty value on the "startdate" and 'enddate" field. How can get this field to display individually?

    My powershell level is a beginner who just completed "powershell in a month of lunches" book. Any input is appreciated.

     

  • #169387

    Senior Moderator
    Topics: 8
    Replies: 1041
    Points: 3,439
    Helping Hand
    Rank: Community Hero

    How can get this field to display individually?

    Didn't get here on what you meant by individually, can you post your expected output here.

  • #169540

    Participant
    Topics: 1
    Replies: 1
    Points: 2
    Rank: Member

    Creating a second property "EndDateFor9020s" by adding line below. That helped fix my issue.

    @{name='EndDateForNon9020'; exp={ForEach-Object -Process{(Get-DellWarranty -ServiceTag $PSItem.serial).enddate -as [datetime]}}}

     

    Very thankful for the interest to help.

    Can be marked "closed"

You must be logged in to reply to this topic.