top of page
Tomas Bjerved

PowerShell: Find duplicate files on a filseserver

Ever needed to find duplicate files on a Windows File-server? You can easily do this with a one-line PowerShell command:


This first example list the hash of the file then the path follow:

Get-ChildItem -Path "D:\data\" -Recurse | Get-FileHash | Group-Object -Property Hash | Where-Object Count -GT 1 | foreach {$_.Group | select Path, Hash}  | out-file .\list_duplicate_files.txt

This version will do the same, but group every file and also show complete file path (in case the path is too long for the first example):

Get-ChildItem -Path "D:\data\" -Recurse | Get-FileHash | Group-Object -Property Hash | Where-Object Count -GT 1 | foreach {$_.Group | select Hash,Path | ft -auto } | out-file .\list_duplicate_files.txt

10 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page