How can I figure out what files are corrupt or missing on my hard drive?

David Orlow 1 Reputation point
2023-02-24T23:18:43.37+00:00

Ok, this is something I've pondered in the past. I have pictures and videos on my NAS for 20 years. Every so often, I start looking around folders and then something sparks a memory and I look for a picture or a video that I remember having and sometimes can't find them. Sometimes I'll find a picture or video that is corrupt.

I have backuips. But, backups are no good if I don't notice it's missing for a year after it's missing and my backups have cycled. I need a way to know when I have missing files or corrupt files. I was thinking for corrupt files, if it could take an inventory of my hard dirve and generate an md5 hash of each file to compare later to let me know if a file has changed.

A while back, I was trying to figure out how to script this. It would be a whole lot nicer if I found a commercial application that was designed for this. Any ideas?

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,195 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,635 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,329 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. S.Sengupta 17,311 Reputation points MVP
    2023-02-25T00:52:17.54+00:00

    To locate the corrupted files, access the CBS.Log. you will find it at:

     

    C:\Windows\Logs\CBS\CBS.log


  2. David Orlow 1 Reputation point
    2023-02-25T01:06:03.7133333+00:00

    this looks promising...

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-filehash?view=powershell-7.3

    I could write a PS script using this commandlet. Maybe I'll just do my own thing again. I've gotten better at scripting since my last attempt and this is a built in tool in the OS...

    0 comments No comments

  3. David Orlow 1 Reputation point
    2023-02-25T02:05:21.7566667+00:00

    This seems to be working... but still would rather a commercial application. I'm going to be messing around with the logic a lot trying to get it right.

    $files = Get-ChildItem z:\ -Recurse | where { ! $_.PSIsContainer } | Select -First 50
    
    foreach ($file in $files) {
        Write-Host "Filename is " + $file.FullName
    
        Get-FileHash $file.FullName -Algorithm SHA384 | Export-Csv -NoTypeInformation C:\Users\dmorl\Documents\2023-02-24-1957-output.csv -Append
    
    }
    
    
    0 comments No comments

  4. David Orlow 1 Reputation point
    2023-02-25T02:27:26.12+00:00

    Maybe the get-filehash won't work... right now, i have it running on 50 of my files and it's taking forever. I'm sure it's taking forever on video files. I have a ton of video files. I dont have enough processing power to push these through fast enough to be useful.

    0 comments No comments

  5. David Orlow 1 Reputation point
    2023-02-25T02:39:20.2033333+00:00

    Got to thinking 384 is excessive. Trying MD5. I know no one is replying. Helps me think though typing it out and maybe it'll help someone else out someday.

    0 comments No comments