[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 }