Skip to content

Instantly share code, notes, and snippets.

@b4tman
Last active April 6, 2023 11:18
Show Gist options
  • Save b4tman/6071d3b9d8e460362db792862cc04cef to your computer and use it in GitHub Desktop.
Save b4tman/6071d3b9d8e460362db792862cc04cef to your computer and use it in GitHub Desktop.
$dups = Get-ChildItem -Recurse -File -Exclude "dups.csv" |
Get-FileHash -Algorithm SHA256 |
Select-Object -Property Hash, Path |
Group-Object -Property Hash |
Where-Object -Property Count -ge 2 |
Sort-Object -Property Count -Descending |
Select-Object -Property Count -ExpandProperty Group |
Select-Object -Property Count, Hash, Path
$dups | ConvertTo-Csv -NoTypeInformation |
Out-File -Encoding utf8 -FilePath "dups.csv"
$dups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment