output on one line

Welcome Forums General PowerShell Q&A output on one line

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

 
Keymaster
1 year, 3 months ago.

  • Author
    Posts
  • #83338

    Participant
    Points: 64
    Rank: Member

    I have the below script that imports a csv that contains the microsoft security bulliten that contains the information from the microsoft security bulliten https://www.microsoft.com/en-us/download/details.aspx?id=36982

    Function Find-Bulletin
    {
    [cmdletbinding()]

    $stripedcsv |Where-Object{($_."Affected Product" -eq $ProductFilter) }
    }

    $stripedcsv = import-csv c:\cve\remove.csv -Header "Date Posted","Bulletin Id","Bulletin KB","Severity","Impact","Title","Affected Product","Component","Affected Component","Impact Level","Severity Old","Supersedes" | ? {$_.Supersedes -ne "" }

    $ProductFilter = "Microsoft Windows XP Service Pack 2"
    Find-Bulletin -ProductFilter $ProductFilter | select 'date posted' ,'affected product', 'bulletin kb' -Unique

    The output currently is as below

    Affected Product Date Posted Bulletin KB
    —————- ———– ———–
    Microsoft Windows XP Service Pack 2 6/8/2010 981343
    Microsoft Windows XP Service Pack 2 6/8/2010 982381
    Microsoft Windows XP Service Pack 2 6/8/2010 980195
    Microsoft Windows XP Service Pack 2 6/8/2010 979902
    Microsoft Windows XP Service Pack 2 6/8/2010 979559
    Microsoft Windows XP Service Pack 2 5/11/2010 978542

    what I would like to achieve is

    Affected Product date posted Bulletin kb date posted Bulletin kb date posted Bulletin kb date posted Bulletin kb
    Microsoft Windows XP Service Pack 6/8/2010 981343 6/8/2010 982381 6/8/2010 980195 6/8/2010 979902

    So the question is
    a) how do I get the output on one line
    b) how to get the affected product to only output once ??

    p.s. I used xp as an example we do not have xp in our environment 🙂

  • #83381

    Keymaster
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Understanding that PowerShell doesn't really output text will help you get where you want to go. You'll have to construct a custom object, giving it the properties that your want included in the output. That will let you pipe your object(s) to Format-Table, which will construct a table that has one object per line, with whatever columns you want as properties.

    You could also pipe the output to Select-Object and use its -unique parameter to only include unique objects. That might help you eliminate duplicates.

The topic ‘output on one line’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort