Script Dumpster: Find duplicate entries over multiple reports

Another day at the office..

Thanks to our friends who wrote the NotPetya worm, I received an email from our monitoring vendor to run reports to see if our machines are up-to-date on their patching.

Unfortunately their reporting tool doesn’t properly distinguish between Windows Server 2008 and Windows 2008 R2, as well as Windows 2012 and Windows 2012 R2.

Long story short,  I had to create 4 separate reports, telling me if I had or had not installed the proper KB item on each machine.

Because of this flaw I also had to join the reports and check the “Highlight Duplicates” option in Excel to see whether or not servers had their respective Hotfix installed (if the server had a duplicate entry, it meant that it didn’t have either the standard or R2 patch installed, meaning vulnerable).

Each report also came with a 3 row header with random junk that needed to be removed, so a simple Ctrl + A , Ctrl + C, Ctrl + V wouldn’t suffice.

PowerShell to the rescue!

I looked at the email from the vendor and went “Hell no, I’m not going to do that…” and opened up PowerShell ISE.

Having dumped the reports in the folder c:\Temp\NotPetya , I came up with the following script:

While the coding took a little bit longer, the execution was swift and perfect.

Geeks and Automation


Happy scripting! 🙂



It never hurts to Get-Help

4 thoughts to “Script Dumpster: Find duplicate entries over multiple reports”

  1. Very cool. One of the reasons why I love PowerShell, the ability to quickly build those “one off” solutions 🙂

    Had a problem with a vendor app that got me into PowerShell the first time almost 10 years ago, their app dumped logs onto the server until it ran out of drive space. The answer (from the vendor) was to manually remove logs over 24 hours old.

    A quick search showed an example on Scripting Guys on how to get rid of files over 7 days old. First time using PowerShell, solution tested and implemented on Test and Prod in 15 minutes. Home early before Rush hour traffic too on a Friday as a result.

    (…and wrote “Highway to PowerShell” on the way home as a result 🙂 )

    1. Some of the most commonly used scripts I guess, cleaning up “files older than” 😀
      Thanks for the comment! Read a lot of your posts before 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *