SMART: износ и температура
Показывает диски с высоким износом, температурой или плохим состоянием здоровья.
Что делает скрипт
Скрипт читает Get-PhysicalDisk и Get-StorageReliabilityCounter и отмечает диски, у которых здоровье не Healthy, износ выше порога или температура выше порога. Для остальных выводится краткая сводка. Счётчики только читаются, тесты не запускаются.
- Счётчики SMART могут быть недоступны без прав администратора и зависят от модели диска.
Быстрый старт
powershell -ExecutionPolicy Bypass -File .\windows_smart.ps1
Скачайте файл, откройте терминал в папке со скриптом и выполните команду. Запускайте в PowerShell 5.1 или PowerShell 7.
Другие варианты
powershell -ExecutionPolicy Bypass -File .\windows_smart.ps1powershell -ExecutionPolicy Bypass -File .\windows_smart.ps1 -WearThreshold 70 -TemperatureThreshold 50powershell -ExecutionPolicy Bypass -File .\windows_smart.ps1 -Json
Что понадобится
Встроен в Windows 10/11 (PowerShell 5.1)
windows_smart.ps1
[CmdletBinding()]
param(
[int]$WearThreshold = 80,
[int]$TemperatureThreshold = 55,
[string]$OutputPath,
[switch]$Json
)
$ErrorActionPreference = 'Stop'
$disks = @(Get-PhysicalDisk -ErrorAction Stop)
$rows = foreach ($disk in $disks) {
$counter = $null
try {
$counter = Get-StorageReliabilityCounter -PhysicalDisk $disk -ErrorAction Stop
} catch {
$counter = $null
}
$wear = $null
$temperature = $null
$powerOnHours = $null
$readErrors = $null
$writeErrors = $null
if ($counter) {
$wear = $counter.Wear
$temperature = $counter.Temperature
$powerOnHours = $counter.PowerOnHours
$readErrors = $counter.ReadErrorsTotal
$writeErrors = $counter.WriteErrorsTotal
}
$alerts = @()
if ([string]$disk.HealthStatus -ne 'Healthy') {
$alerts += "health=$($disk.HealthStatus)"
}
if ($null -ne $wear -and $wear -ge $WearThreshold) {
$alerts += "wear=$wear"
}
if ($null -ne $temperature -and $temperature -ge $TemperatureThreshold) {
$alerts += "temp=$temperature"
}
[pscustomobject]@{
Disk = $disk.FriendlyName
SizeGB = [math]::Round($disk.Size / 1GB, 1)
Health = [string]$disk.HealthStatus
Wear = $wear
Temperature = $temperature
PowerOnHours = $powerOnHours
ReadErrors = $readErrors
WriteErrors = $writeErrors
Alerts = ($alerts -join '; ')
}
}
$rows = $rows | Sort-Object @{ Expression = { @($_.Alerts).Count }; Descending = $true }, Disk
$problem = @($rows | Where-Object { $_.Alerts })
Write-Host "Дисков: $(@($rows).Count), с замечаниями: $($problem.Count)"
if ($Json) {
$text = $rows | ConvertTo-Json -Depth 4
} else {
$text = $rows | Format-Table -Wrap | Out-String -Width 240
}
if ($OutputPath) {
$text | Set-Content -LiteralPath $OutputPath -Encoding UTF8
Write-Host "Отчёт сохранён: $OutputPath"
} else {
$text
}
Скрипты работают с файлами и настройками системы. Перед запуском прочитайте код и проверьте пути. Особенно если скрипт удаляет, перезаписывает или перемещает данные.