MOAR wips
This commit is contained in:
parent
9724882578
commit
b591f9f5b7
|
@ -0,0 +1,9 @@
|
|||
rem Block Win11 upgrade
|
||||
|
||||
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersion /t REG_DWORD /d 1
|
||||
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate /f /v TargetReleaseVersionInfo /t REG_SZ /d 21H2
|
||||
|
||||
rem classic start menu and left side settings:
|
||||
|
||||
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Start_ShowClassicMode /t REG_DWORD /d 1
|
||||
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarAl /t REG_DWORD /d 0
|
|
@ -0,0 +1,18 @@
|
|||
$ErrorActionPreference= 'silentlycontinue'
|
||||
$smartst = (Get-WmiObject -namespace root\wmi -class MSStorageDriver_FailurePredictStatus).PredictFailure
|
||||
|
||||
if ($smartst = 'False')
|
||||
{
|
||||
Write-Output "Theres no SMART Failures predicted"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
Write-Output "There are SMART Failures detected"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
Exit $LASTEXITCODE
|
|
@ -0,0 +1,129 @@
|
|||
# If this is a virtual machine, we don't need to continue
|
||||
$Computer = Get-CimInstance -ClassName 'Win32_ComputerSystem'
|
||||
if ($Computer.Model -like 'Virtual*') {
|
||||
exit
|
||||
}
|
||||
|
||||
$disks = (Get-CimInstance -Namespace 'Root\WMI' -ClassName 'MSStorageDriver_FailurePredictStatus' |
|
||||
Select-Object 'InstanceName')
|
||||
|
||||
$Warnings = @()
|
||||
|
||||
foreach ($disk in $disks.InstanceName) {
|
||||
# Retrieve SMART data
|
||||
$SmartData = (Get-CimInstance -Namespace 'Root\WMI' -ClassName 'MSStorageDriver_ATAPISMartData' |
|
||||
Where-Object 'InstanceName' -eq $disk)
|
||||
|
||||
[Byte[]]$RawSmartData = $SmartData | Select-Object -ExpandProperty 'VendorSpecific'
|
||||
|
||||
# Starting at the third number (first two are irrelevant)
|
||||
# get the relevant data by iterating over every 12th number
|
||||
# and saving the values from an offset of the SMART attribute ID
|
||||
[PSCustomObject[]]$Output = for ($i = 2; $i -lt $RawSmartData.Count; $i++) {
|
||||
if (0 -eq ($i - 2) % 12 -and $RawSmartData[$i] -ne 0) {
|
||||
# Construct the raw attribute value by combining the two bytes that make it up
|
||||
[Decimal]$RawValue = ($RawSmartData[$i + 6] * [Math]::Pow(2, 8) + $RawSmartData[$i + 5])
|
||||
|
||||
$InnerOutput = [PSCustomObject]@{
|
||||
DiskID = $disk
|
||||
ID = $RawSmartData[$i]
|
||||
#Flags = $RawSmartData[$i + 1]
|
||||
#Value = $RawSmartData[$i + 3]
|
||||
Worst = $RawSmartData[$i + 4]
|
||||
RawValue = $RawValue
|
||||
}
|
||||
|
||||
$InnerOutput
|
||||
}
|
||||
}
|
||||
|
||||
# Reallocated Sectors Count
|
||||
$Warnings += $Output | Where-Object ID -eq 5 | Where-Object RawValue -gt 1 | Format-Table
|
||||
|
||||
# Spin Retry Count
|
||||
$Warnings += $Output | Where-Object ID -eq 10 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Recalibration Retries
|
||||
$Warnings += $Output | Where-Object ID -eq 11 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Used Reserved Block Count Total
|
||||
$Warnings += $Output | Where-Object ID -eq 179 | Where-Object RawValue -gt 1 | Format-Table
|
||||
|
||||
# Erase Failure Count
|
||||
$Warnings += $Output | Where-Object ID -eq 182 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# SATA Downshift Error Count or Runtime Bad Block
|
||||
$Warnings += $Output | Where-Object ID -eq 183 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# End-to-End error / IOEDC
|
||||
$Warnings += $Output | Where-Object ID -eq 184 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Reported Uncorrectable Errors
|
||||
$Warnings += $Output | Where-Object ID -eq 187 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Command Timeout
|
||||
$Warnings += $Output | Where-Object ID -eq 188 | Where-Object RawValue -gt 2 | Format-Table
|
||||
|
||||
# High Fly Writes
|
||||
$Warnings += $Output | Where-Object ID -eq 189 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Temperature Celcius
|
||||
$Warnings += $Output | Where-Object ID -eq 194 | Where-Object RawValue -gt 50 | Format-Table
|
||||
|
||||
# Reallocation Event Count
|
||||
$Warnings += $Output | Where-Object ID -eq 196 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Current Pending Sector Count
|
||||
$Warnings += $Output | Where-Object ID -eq 197 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Uncorrectable Sector Count
|
||||
$Warnings += $Output | Where-Object ID -eq 198 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# UltraDMA CRC Error Count
|
||||
$Warnings += $Output | Where-Object ID -eq 199 | Where-Object RawValue -ne 0 | Format-Table
|
||||
|
||||
# Soft Read Error Rate
|
||||
$Warnings += $Output | Where-Object ID -eq 201 | Where-Object Worst -lt 95 | Format-Table
|
||||
|
||||
# SSD Life Left
|
||||
$Warnings += $Output | Where-Object ID -eq 231 | Where-Object Worst -lt 50 | Format-Table
|
||||
|
||||
# SSD Media Wear Out Indicator
|
||||
$Warnings += $Output | Where-Object ID -eq 233 | Where-Object Worst -lt 50 | Format-Table
|
||||
|
||||
}
|
||||
|
||||
$Warnings += Get-CimInstance -Namespace 'Root\WMI' -ClassName 'MSStorageDriver_FailurePredictStatus' |
|
||||
Select-Object InstanceName, PredictFailure, Reason |
|
||||
Where-Object {$_.PredictFailure -ne $False} | Format-Table
|
||||
|
||||
$Warnings += Get-CimInstance -ClassName 'Win32_DiskDrive' |
|
||||
Select-Object Model, SerialNumber, Name, Size, Status |
|
||||
Where-Object {$_.status -ne 'OK'} | Format-Table
|
||||
|
||||
$Warnings += Get-PhysicalDisk |
|
||||
Select-Object FriendlyName, Size, MediaType, OperationalStatus, HealthStatus |
|
||||
Where-Object {$_.OperationalStatus -ne 'OK' -or $_.HealthStatus -ne 'Healthy'} | Format-Table
|
||||
|
||||
if ($Warnings) {
|
||||
$Warnings = $warnings | Out-String
|
||||
$Warnings
|
||||
Write-Output "There are SMART impending Failures"
|
||||
Write-Output "$Warnings"
|
||||
Exit 2
|
||||
}
|
||||
|
||||
elseif ($Error) {
|
||||
Write-Output "There were errors detecting smart on this system"
|
||||
Write-Output "$Error"
|
||||
exit 1
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Write-Output "There are no SMART Failures detected"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
Exit $LASTEXITCODE
|
Loading…
Reference in New Issue