Home > Software engineering >  Select not unique in PowerShell
Select not unique in PowerShell

Time:10-30

found some examples to search for double entries but they didn't work for me with checksums. What is wrong in that approach ?

$arrDouble = "37B8525F4EE3571AA43F0F61C64060D5", "37B8525F4EE3571AA43F0F61C64060D5", "1E7100E795F6B84778EE0C6795AC8E32"
$HashesUnique = $arrDouble | Select-Object -Unique
$HashesDouble = $arrDouble | Where-Object {$_.count -gt 1}
$HashesUnique
$HashesDouble

is there any NOT for Select-Object -Unique or Get-Unique ? Unique works fine

CodePudding user response:

Something like this should get you the duplicate hashes:

$arrDouble = "37B8525F4EE3571AA43F0F61C64060D5", "37B8525F4EE3571AA43F0F61C64060D5", "1E7100E795F6B84778EE0C6795AC8E32"

$hashesDouble = ($arrDouble | Group-Object | Where-Object Count -gt 1).Group | Select-Object -Unique

$hashesDouble

The output should be a list of hashes that appear more than once in $arrDouble: 37B8525F4EE3571AA43F0F61C64060D5

  • Related