Using PowerShell to remove duplicates in a SharePoint list

I recently had the requirement to remove all the duplicate values out of a SharePoint list. It turned out that the items were not completely unique, but shared multiple column values. After many failed attempts and intense google-fu, I found the following PowerShell script on a blog that had found it on a different blog.

I think this is a very elegant solution, it groups items in the given list by a number of columns and then either lists all the items or deletes all but the first item in each group.