Windows PowerShell to find duplicate lines in a file

powershell, powershell-2.0

Solution

You can also use the Group-Object cmdlet to see if any lines occur more than once:

e.g.

Get-Content test.txt | Group-Object | Where-Object { $_.Count -gt 1 } | Select -ExpandProperty Name

Problem

I need to find the duplicate values in a text file using power shell let's say if the file content is ``` Apple Orange Banana Orange Orange ``` Desired output should be ``` Orange Orange ```

Original source

Related problems