GithubHelp home page GithubHelp logo

joeltimothyoh / get-smartreport Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 30 KB

Generates a report regarding the SMART status of physical drives on the system.

License: GNU General Public License v3.0

PowerShell 100.00%
smart-status drive-status drive-health drive-reliability hdd hdd-status hdd-health powershell

get-smartreport's Introduction

Get-SMARTReport

Generates a report regarding the SMART status of physical drives on the system.

Deprecation notice

This script / module outputs the SMART status of physical drives on the system in a custom format as array of strings rather than as objects for consumption further down a pipeline, making it unmodular and very much anthetical to PowerShell's general design and approach in dealing with objects rather than strings.

To get the same SMART statuses of physical drives, simply use PowerShell's built-in Get-WmiObject:

# Get disk drive objects, selecting property 'Status'
Get-WmiObject -Class Win32_DiskDrive | Select-Object Status
# In tabular format
Get-WmiObject -Class Win32_DiskDrive | Select-Object Partitions,DeviceID,Model,Size,Caption,Status | Sort-Object DeviceID | Format-Table -AutoSize

Having used the script in production for a daily report on several systems for a number of years, the status of drives have never reported as anything else other than OK despite a number of hard drives failing during the period. I believe OK statuses are consistent with Windows' general behavior of not reporting on failing drives even when they are screeching to a halt with the only indication of impending disk failure being especially high read/write durations and Windows Explorer becoming unresponsive. SMART detection as a feature is likely deliberately left out of the operating system to create a market for the existence of third party disk management software.

If you're a consumer, consider using tools such as CrystalDiskInfo for interactively checking the health of physical disks on a system. For production uses, consider using more reliable forms of storage such as mid-range SSDs or NVMe drives rather than hard drives, or, if possible, remote or cloud storage solutions where disks are managed by storage providers.

Also, instead of relying on emails, consider using tools (e.g. Prometheus) for monitoring and alerting at scale.

Description

The report will include a warning when one or more physical drives return a SMART status other than 'OK'.

Usage

Get-SMARTReport can be used as a script or module. Scripts allow for greater portability and isolation, while modules allow for greater accessibility, scalability and upgradability.

The Get-SMARTReport.ps1 script has the additional ability to email reports.

Script

  • Specify email settings within the Get-SMARTReport.ps1 script.
  • Run the script to get a report and send it via email.

Module

  • Install the Get-SMARTReport.psm1 module. Refer to Microsoft's documentation on installing PowerShell modules.
  • Call the module via Get-SMARTReport in PowerShell to get a report.

Scheduling

The Get-SMARTReport.ps1 script can be scheduled to periodically notify on the operational status of physical drives on the system.

  • Set up the script to be run.
  • In Task Scheduler, create a task with the following Action:
    • Action: Start a program
    • Program/script: Powershell
    • Add arguments (optional): "C:\path\to\script.ps1"
  • Repeat the steps for each script that is to be scheduled.

Refer to Microsoft's documentation or guides for further help on using Task Scheduler.

Parameters

Get-SMARTReport [<CommonParameters>]

PARAMETERS
    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).

Examples

Example 1

Runs the Get-SMARTReport.ps1 script in an instance of PowerShell.

Powershell "C:\scripts\Get-SMARTReport\Get-SMARTReport.ps1"

Example 2

Runs the Get-SMARTReport module, appending the output to the specified log file.

Get-SMARTReport >> "C:\logs\smart-report.log"

Security

Unverified scripts are restricted from running on Windows by default. In order to use Get-SMARTReport, you will need to allow the execution of unverified scripts. To do so, open PowerShell as an Administrator. Then run the command:

Set-ExecutionPolicy Unrestricted -Force

If you wish to revert the policy, run the command:

Set-ExecutionPolicy Undefined -Force

Requirements

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.