CrystalDiskInfo Disk Health Report

Looking to get a health disk report installed on endpoints that uses command “winget install -e --id CrystalDewWorld.CrystalDiskInfo” to install the app, then runs the command line parameter

“C:\Program Files\CrystalDiskInfo\DiskInfo64.exe” /CopyExit

The generated txt file would need to then be emailed through to my email address, a file called “DiskInfo.txt” is created.

Hello Kynect Gov@ativo,

Install CrystalDiskInfo using the winget command.

winget install -e --id CrystalDewWorld.CrystalDiskInfo

Run CrystalDiskInfo with the command line parameter to generate the report:.

"C:\Program Files\CrystalDiskInfo\DiskInfo64.exe" /CopyExit

Email the Report: You’ll need a script that sends an email with the “DiskInfo.txt” as an attachment. This can be done using PowerShell, Python, or any other scripting language that supports SMTP email sending.

$smtpServer = "your.smtp.server"
$smtpFrom = "from@example.com"
$smtpTo = "your.email@example.com"
$messageSubject = "CrystalDiskInfo Disk Health Report"
$messageBody = "Attached is the Disk Health Report generated by CrystalDiskInfo."
$attachmentPath = "C:\Program Files\CrystalDiskInfo\DiskInfo.txt"

# Create a new object for the email
$emailMessage = New-Object System.Net.Mail.MailMessage($smtpFrom, $smtpTo, $messageSubject, $messageBody)

# Add the attachment
$attachment = New-Object System.Net.Mail.Attachment($attachmentPath)
$emailMessage.Attachments.Add($attachment)

# Send the email
$smtpClient = New-Object Net.Mail.SmtpClient($smtpServer)
$smtpClient.Send($emailMessage)

Make sure to replace “your.smtp.server”, “from@example. com”, and “your.email@example. com” with your actual SMTP server and email addresses. Also, ensure that the path to the “DiskInfo.txt” file is correct.

Please note that this script assumes you have the necessary permissions to send emails through the specified SMTP server and that the server is configured to allow such operations.

Best Regards,
Kynect Gov

Hi Kynect Gov,

Thank you for this, how do I create a script on Xcitium under procedures to run with adding in parameters so that the email details do not get added to the end device?

This script looks significantly shorter than other procedures that can be downloaded and run. I have tried this procedure which fails.

https://scripts.xcitium.com/frontend/web/topic/disk-alert-event-and-send-notificationemail

Thank you.

Hello there @ativo,

To automate the process of installing CrystalDiskInfo, generating a disk health report, and emailing it to your address, you can use a script. Below is a PowerShell script that accomplishes these tasks.

# Install CrystalDiskInfo using winget
winget install -e --id CrystalDewWorld.CrystalDiskInfo

# Run CrystalDiskInfo with the command line parameter to generate DiskInfo.txt
& "C:\Program Files\CrystalDiskInfo\DiskInfo64.exe" /CopyExit

# Define the path to the generated DiskInfo.txt
$diskInfoPath = "C:\Program Files\CrystalDiskInfo\DiskInfo.txt"

# Check if DiskInfo.txt was generated
if (Test-Path $diskInfoPath) {
    # Email parameters
    $smtpServer = "your.smtp.server"
    $smtpFrom = "your-email@example.com"
    $smtpTo = "recipient-email@example.com"
    $messageSubject = "Disk Health Report"
    $messageBody = "Attached is the disk health report generated by CrystalDiskInfo."
    $attachment = New-Object System.Net.Mail.Attachment($diskInfoPath)

    # Create a MailMessage object
    $message = New-Object System.Net.Mail.MailMessage
    $message.From = $smtpFrom
    $message.To.Add($smtpTo)
    $message.Subject = $messageSubject
    $message.Body = $messageBody
    $message.Attachments.Add($attachment)

    # Send the email
    $smtp = New-Object Net.Mail.SmtpClient($smtpServer)
    $smtp.Send($message)
    "Disk health report emailed successfully."
} else {
    "DiskInfo.txt was not found. Please check if CrystalDiskInfo is installed correctly and the path is correct."
}

Please replace “your.smtp.server”, “your-email@example.com”, and “recipient-email@example.com” with your actual SMTP server and email addresses. Also, ensure that the SMTP server allows sending emails through scripts.

This script will be Install CrystalDiskInfo using the winget command.
Execute CrystalDiskInfo with the /CopyExit parameter to generate the DiskInfo.txt file.
Check if the DiskInfo.txt file exists.
If it exists, it will create an email with the disk health report as an attachment and send it to the specified email address.
If the file does not exist, it will output an error message.
Make sure to run this script with appropriate permissions and test it in a controlled environment before deploying it to production. Also, be aware of any security policies that might restrict the execution of scripts or the sending of emails from your network.

Hi,

Thank you for this, how do I run this as an Itarian procedure script, to my understanding, native powershell does not work for Itarian procedures.

Is it possible to configure the secure aspects of the script as parameters so that no confidential SMTP credentials are used and giving the option of also using gmail/outlook.com.

Thank you.