Author Posts

November 1, 2017 at 10:38 am

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 🙂

November 1, 2017 at 2:52 pm

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.