Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions scripts_wip/Win_Battery_Capacity_Check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ if ($absoluteValues) {
$label = "mWh"
}

If($available -le $minimumBatteryCapacity)
{
Write-Output "The battery needs investigating. Full charge capacity is below the threshold of $minimumBatteryCapacity $label ($available $label available of design capacity $designCapacity mWh."
Exit 1
} else {
Write-Output "The battery is reporting ok. Full charge capacity is above the threshold of $minimumBatteryCapacity $label ($available $label available of design capacity $designCapacity mWh."
Exit 0
}
"Full charge capacity $available$label of $designCapacity mWh."

If($available -le $minimumBatteryCapacity){ Exit 1 }
Exit 0
10 changes: 5 additions & 5 deletions scripts_wip/Win_CPU_Uptime_Check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Param(
$uptime = (get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty LastBootUpTime)
#v7 introduces Get-Uptime, but using WMI is backwards compatiable with v5

If($uptime.TotalHours -ge $maximumUptimeHoursWarningLimit){
"Uptime is over threshold ($($uptime.TotalHours)/$maximumUptimeHoursWarningLimit)"
Exit 1
}
$hiberbootEnabled = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name 'HiberbootEnabled' -ErrorAction Stop).HiberbootEnabled
[bool]$FastStartupEnabled = ($hiberbootEnabled -eq 1)

"Uptime is below threshold ($($uptime.TotalHours)/$maximumUptimeHoursWarningLimit)"
"CPU Uptime $([math]::Round($uptime.TotalHours,2)) hours. Fast Startup enabled: $FastStartupEnabled"

If($uptime.TotalHours -ge $maximumUptimeHoursWarningLimit){ Exit 1 }
Exit 0
36 changes: 14 additions & 22 deletions scripts_wip/Win_Disk_HealthCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
Param(
[Parameter(Mandatory = $false)]
[int]#Warn if the temperature (in degrees C) is over this limit
$TemperatureWarningLimit = 55,
$TemperatureWarningLimit = 60,

[Parameter(Mandatory = $false)]
[int]#Warn if the "wear" of the drive (as a percentage) is above this
$maximumWearAllowance = 20,

[Parameter(Mandatory = $false)]
[switch]#Outputs a full report, instead of warnings only
$fullReport
$maximumWearAllowance = 20
)

BEGIN {
Expand All @@ -41,7 +37,6 @@ PROCESS {
Try{
#Using Windows Storage Reliabilty Counters first (the information behind Settings - Storage - Disks & Volumes - %DiskID% - Drive health)
$physicalDisks = Get-PhysicalDisk -ErrorAction Stop
$storageResults = @()
foreach ($disk in $physicalDisks) {
$reliabilityCounter = $null
try {
Expand All @@ -50,43 +45,40 @@ PROCESS {
catch {
Write-Error "No Storage Reliability Counter for '$($disk.FriendlyName)'. This usually means the driver/controller isn't exposing it."
}
$driveLetters = (get-disk -FriendlyName $Disk.FriendlyName | Get-Partition | Where-Object -FilterScript {$_.DriveLetter} | Select-Object -Expand DriveLetter) -join ", "

$storageResults += [pscustomobject]@{
<#
DriveLetters = $driveLetters
HealthStatus = $disk.HealthStatus
FriendlyName = $disk.FriendlyName
SerialNumber = $disk.SerialNumber
BusType = $disk.BusType
HealthStatus = $disk.HealthStatus
OperationalStatus = ($disk.OperationalStatus -join ", ")
Temperature = $reliabilityCounter.Temperature
Wear = $reliabilityCounter.Wear
ReadErrorsTotal = $reliabilityCounter.ReadErrorsTotal
WriteErrorsTotal = $reliabilityCounter.WriteErrorsTotal
ReallocatedSectors = $reliabilityCounter.ReallocatedSectors
PowerOnHours = $reliabilityCounter.PowerOnHours
}

#>
If(
$disk.HealthStatus.ToLower() -ne "healthy" -or
($disk.OperationalStatus | Where-Object -FilterScript { $_.ToLower() -ne "ok" }) -or
$reliabilityCounter.Wear -ge $maximumWearAllowance -or
$reliabilityCounter.Temperature -ge $TemperatureWarningLimit
$reliabilityCounter.Wear -gt $maximumWearAllowance -or
$reliabilityCounter.Temperature -gt $TemperatureWarningLimit
){
Write-Error -Message "$($disk.FriendlyName) has conditions that require investigation. $storageResults"
"Disk issue: $DriveLetters $($disk.HealthStatus) Status:$(($disk.OperationalStatus -join ", ")) $($reliabilityCounter.Temperature)*C $($reliabilityCounter.Wear)% wear"
Write-Error -Message "Disk issues need investigating"
} else {
"$DriveLetters $($disk.HealthStatus) Status:$(($disk.OperationalStatus -join ", ")) $($reliabilityCounter.Temperature)*C $($reliabilityCounter.Wear)% wear"
}
}

If($fullReport) { $storageResults }

} catch {
Write-Error -Message "Get-PhysicalDisk failed. This can happen on older OS builds or restricted environments."
}
}

END{
if ($error) {
Write-Output $error
exit 1
}
Write-Output "All drives report as healthy"
if ($error) { Exit 1 }
Exit 0
}
215 changes: 0 additions & 215 deletions scripts_wip/Win_Disk_SMART.ps1

This file was deleted.

Loading