mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-09 18:19:32 +02:00
Update check-smart-devices.ps1
This commit is contained in:
parent
bbd7a6c36c
commit
551ea988e4
@ -2,10 +2,10 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks SMART devices
|
Checks SMART devices
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script queries and prints your S.M.A.R.T. HDD/SSD devices.
|
This PowerShell script queries S.M.A.R.T. HDD/SSD device details and prints it.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-smart-devices
|
PS> ./check-smart-devices
|
||||||
✅ Device HFM256GD3JX016N (256GB) via NVMe, 29°C, 71 hours, 126x on, selftest passed.
|
✅ 1TB Samsung SSD 970 EVO via NVMe, 37°C, 2388 hours, 289x on, v2B2QEXE7, selftest passed.
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -47,8 +47,14 @@ try {
|
|||||||
continue
|
continue
|
||||||
} elseif ($IsLinux) {
|
} elseif ($IsLinux) {
|
||||||
$Details = (sudo smartctl --all --json $Device) | ConvertFrom-Json
|
$Details = (sudo smartctl --all --json $Device) | ConvertFrom-Json
|
||||||
|
if ($lastExitCode -ne "0") { throw "'sudo smartctl --all --json $Device' exited with error code $lastExitCode" }
|
||||||
|
$null = (sudo smartctl --test=short $Device)
|
||||||
|
if ($lastExitCode -ne "0") { throw "'sudo smartctl --test=short $Device' exited with error code $lastExitCode" }
|
||||||
} else {
|
} else {
|
||||||
$Details = (smartctl --all --json $Device) | ConvertFrom-Json
|
$Details = (smartctl --all --json $Device) | ConvertFrom-Json
|
||||||
|
if ($lastExitCode -ne "0") { throw "'smartctl --all --json $Device' exited with error code $lastExitCode" }
|
||||||
|
$null = (smartctl --test=short $Device)
|
||||||
|
if ($lastExitCode -ne "0") { throw "'smartctl --test=short $Device' exited with error code $lastExitCode" }
|
||||||
}
|
}
|
||||||
$ModelName = $Details.model_name
|
$ModelName = $Details.model_name
|
||||||
$Protocol = $Details.device.protocol
|
$Protocol = $Details.device.protocol
|
||||||
@ -69,4 +75,4 @@ try {
|
|||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user