PowerShell help needed - SMART data parser from CrystalDiskInfo



  • Luke Nichols


    It looks like you are not the first person to try to tackle this issue in this way. Try using the method here:


    Comment actions Permalink
  • Marek Šnapka

    Yes, Luke, that is surely true, however, this script does not pull any data into PDQ.

    Comment actions Permalink
  • Luke Nichols


    I mistakenly assumed you were familiar with PDQ PowerShell scanners and just needed to solve getting the data from CrystalDiskInfo. I have been able to get all of the attributes of a single disk into a PDQ scanner with this:


    #Replace the Download URL to where you've uploaded the ZIP file yourself. We will only download this file once. 
    $DownloadURL = "\\server\name\CrystalDiskInfo8_16_4.zip"
    $DownloadLocation = "$($Env:ProgramFiles)\CrystalDiskInfo"
    $TestDownloadLocation = Test-Path $DownloadLocation
        new-item $DownloadLocation -ItemType Directory -force
        Invoke-WebRequest -Uri $DownloadURL -OutFile "$($DownloadLocation)\CrystalDiskInfo.zip"
    Expand-Archive "$($DownloadLocation)\CrystalDiskInfo.zip" -DestinationPath $DownloadLocation -Force
    #We start CrystalDiskInfo with the COPYEXIT parameter. This just collects the SMART information in DiskInfo.txt
    Start-Process "$($Env:ProgramFiles)\CrystalDiskInfo\DiskInfo64.exe" -ArgumentList "/CopyExit" -wait
    $DiskInfoRaw  = get-content "$($Env:ProgramFiles)\CrystalDiskInfo\DiskInfo.txt" | select-string "-- S.M.A.R.T. --------------------------------------------------------------" -Context 0,15
    $diskinfo = $DiskInfoRaw -split "`n" | select -skip 2 | Out-String | ConvertFrom-Csv -Delimiter " " -Header "Unused1","Unused2","ID","Cur","Wor","Thr","RawValue","AttributeName1","AttributeName2","AttributeName3","AttributeName4","AttributeName5"# | Select-Object ID,RawValue
    $diskinfo = $diskinfo | Select-Object AttributeName1,AttributeName2,AttributeName3,AttributeName4,AttributeName5,RawValue

    foreach ($Attribute in $diskinfo) {
            AttributeName = ("$($Attribute.AttributeName1) $($Attribute.AttributeName2) $($Attribute.AttributeName3) $($Attribute.AttributeName4) $($Attribute.AttributeName5)").Trim()
            Value = [UInt64]"0x$($Attribute.RawValue)"


    Example output:

    AttributeName                           Value
    -------------                           -----
    Reallocated Sector Count                    1
    Power-on Hours                          74969
    Power-on Count                            321
    Wear Leveling Count                        27
    Used Reserved Block Count (Total)           1
    Program Fail Count (Total)                  0
    Erase Fail Count (Total)                    1
    Runtime Bad Block (Total)                   1
    Uncorrectable Error Count                   0
    Airflow Temperature                        34
    ECC Error Rate                              0
    CRC Error Count                             0
    POR Recovery Count                         13
    Total LBAs Written                73391344057

    I had to make some changes to the script in the web page I linked because it did everything by attribute ID and all of those IDs were wrong for my environment. I switched to using attribute name which seems to work better. I also had to change the data type to [UInt64] because some of the attributes (namely Total LBAs written) did not fit in a [UInt32] data type.

    Unfortunately this does not support multiple disks and does not grab the health status from the text file, but it's a starting point. I'll probably play around with this a bit more but since we don't use this in my environment I can't spend a lot of time on it. I hope this has helped you get to a starting point at least.

    Comment actions Permalink

Please sign in to leave a comment.