@@ -699,10 +699,21 @@ function Test-Trim {
699699 }
700700 $txt = $map.GetEnumerator () | ForEach-Object {
701701 $status = if ($_.Value -eq " 0" ) { " Enabled" } else { " Disabled" }
702- " $ ( $_.Key ) : $status "
702+ " $ ( $_.Key ) : TRIM $status "
703703 }
704704 if (-not $txt ) { $txt = @ (" TRIM status unknown" ) }
705705
706+ if ($map.Count -gt 0 ) {
707+ $enabledCount = ($map.GetEnumerator () | Where-Object { $_.Value -eq " 0" }).Count
708+ if ($enabledCount -eq $map.Count ) {
709+ $txt += " Overall: TRIM is ENABLED"
710+ } elseif ($enabledCount -eq 0 ) {
711+ $txt += " Overall: TRIM is DISABLED"
712+ } else {
713+ $txt += " Overall: TRIM mixed (check per-filesystem status)"
714+ }
715+ }
716+
706717 $script :TestResults += @ {
707718 Tool = " SSD-TRIM" ; Description = " TRIM status"
708719 Status = " SUCCESS" ; Output = ($txt -join " `n " ); Duration = 50
@@ -971,17 +982,25 @@ function Test-GPU {
971982 $gpus = Get-CimInstance Win32_VideoController
972983 foreach ($gpu in $gpus ) {
973984 if ($gpu.Name ) {
974- $year = if ($gpu.DriverDate ) {
975- ([DateTime ]$gpu.DriverDate ).Year
976- } else {
977- 2020
985+ $driverYear = $null
986+ if ($gpu.DriverDate ) {
987+ try {
988+ $driverYear = ([DateTime ]$gpu.DriverDate ).Year
989+ } catch {
990+ $driverYear = $null
991+ }
978992 }
979-
980- $featureLevel = if ($year -ge 2020 ) { " 12_x" }
981- elseif ($year -ge 2016 ) { " 12_0" }
982- elseif ($year -ge 2012 ) { " 11_0" }
993+
994+ if (-not $driverYear ) {
995+ # Fall back to a conservative default if parsing fails
996+ $driverYear = 2014
997+ }
998+
999+ $featureLevel = if ($driverYear -ge 2020 ) { " 12_x" }
1000+ elseif ($driverYear -ge 2016 ) { " 12_0" }
1001+ elseif ($driverYear -ge 2012 ) { " 11_0" }
9831002 else { " 10_x" }
984-
1003+
9851004 $capabilities += " $ ( $gpu.Name ) : Likely supports DirectX $featureLevel "
9861005 }
9871006 }
@@ -1036,23 +1055,43 @@ function Test-GPUVendorSpecific {
10361055
10371056 # Check for AMD
10381057 try {
1039- $amdRegistry = " HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000"
1040-
1041- if (Test-Path $amdRegistry ) {
1042- $amdInfo = Get-ItemProperty $amdRegistry - ErrorAction Stop
1043-
1044- $amdOutput = @ ()
1045- $amdOutput += " AMD GPU Detected"
1046- $amdOutput += " Driver Description: $ ( $amdInfo.DriverDesc ) "
1047- $amdOutput += " Driver Version: $ ( $amdInfo.DriverVersion ) "
1048- $amdOutput += " Driver Date: $ ( $amdInfo.DriverDate ) "
1049-
1050- if ($amdInfo.DriverDesc -match " AMD|Radeon" ) {
1058+ $amdClassRoot = " HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
1059+
1060+ if (Test-Path $amdClassRoot ) {
1061+ $amdOutputs = @ ()
1062+ $detected = $false
1063+
1064+ $subKeys = Get-ChildItem $amdClassRoot - ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -match " ^\d{4}$" }
1065+ foreach ($subKey in $subKeys ) {
1066+ try {
1067+ $amdInfo = Get-ItemProperty $subKey.PSPath - ErrorAction Stop
1068+ } catch {
1069+ continue
1070+ }
1071+
1072+ if ($amdInfo.DriverDesc -and $amdInfo.DriverDesc -match " AMD|Radeon" ) {
1073+ $detected = $true
1074+ $amdOutputs += " AMD GPU Slot $ ( $subKey.PSChildName ) "
1075+ $amdOutputs += " Driver Description: $ ( $amdInfo.DriverDesc ) "
1076+ if ($amdInfo.DeviceDesc ) { $amdOutputs += " Device: $ ( $amdInfo.DeviceDesc ) " }
1077+ if ($amdInfo.DriverVersion ) { $amdOutputs += " Driver Version: $ ( $amdInfo.DriverVersion ) " }
1078+ if ($amdInfo.DriverDate ) { $amdOutputs += " Driver Date: $ ( $amdInfo.DriverDate ) " }
1079+ $amdOutputs += " "
1080+ }
1081+ }
1082+
1083+ if ($detected ) {
10511084 $script :TestResults += @ {
10521085 Tool = " AMD-GPU" ; Description = " AMD GPU information"
1053- Status = " SUCCESS" ; Output = ($amdOutput -join " `n " ); Duration = 100
1086+ Status = " SUCCESS" ; Output = ($amdOutputs -join " `n " ); Duration = 150
10541087 }
10551088 Write-Host " AMD GPU information collected" - ForegroundColor Green
1089+ } else {
1090+ Write-Host " AMD GPU not detected" - ForegroundColor DarkGray
1091+ $script :TestResults += @ {
1092+ Tool = " AMD-GPU" ; Description = " AMD GPU information"
1093+ Status = " SKIPPED" ; Output = " No AMD GPU detected" ; Duration = 0
1094+ }
10561095 }
10571096 } else {
10581097 Write-Host " AMD GPU not detected" - ForegroundColor DarkGray
@@ -1181,6 +1220,8 @@ function Test-HardwareEvents {
11811220function Test-WindowsUpdate {
11821221 Write-Host " `n === Windows Update ===" - ForegroundColor Green
11831222 $updateSession = $null
1223+ $searcher = $null
1224+ $result = $null
11841225 try {
11851226 $lines = @ ()
11861227 try {
@@ -1226,6 +1267,12 @@ function Test-WindowsUpdate {
12261267 } catch {
12271268 Write-Host " Windows Update check failed" - ForegroundColor Yellow
12281269 } finally {
1270+ if ($result ) {
1271+ try { [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($result ) | Out-Null } catch {}
1272+ }
1273+ if ($searcher ) {
1274+ try { [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($searcher ) | Out-Null } catch {}
1275+ }
12291276 if ($updateSession ) {
12301277 try { [System.Runtime.InteropServices.Marshal ]::ReleaseComObject($updateSession ) | Out-Null } catch {}
12311278 }
@@ -1533,14 +1580,16 @@ function Generate-Report {
15331580
15341581 # === GPU HEALTH ===
15351582 if ($gpuDetails ) {
1536- if ($gpuDetails.Output -match " Driver Date:.*(\d{4})" ) {
1537- $driverYear = [int ]$matches [1 ]
1538- $currentYear = (Get-Date ).Year
1539- if ($currentYear - $driverYear -gt 1 ) {
1540- $recommendations += " • INFO: GPU drivers are over 1 year old"
1541- $recommendations += " → Update to latest drivers for best performance"
1542- $recommendations += " → NVIDIA: GeForce Experience or nvidia.com"
1543- $recommendations += " → AMD: amd.com/en/support"
1583+ if ($gpuDetails.Output -match " Driver Date:.*?(\d{4})" ) {
1584+ $driverYear = 0
1585+ if ([int ]::TryParse($matches [1 ], [ref ]$driverYear )) {
1586+ $currentYear = (Get-Date ).Year
1587+ if ($currentYear - $driverYear -gt 1 ) {
1588+ $recommendations += " • INFO: GPU drivers are over 1 year old"
1589+ $recommendations += " → Update to latest drivers for best performance"
1590+ $recommendations += " → NVIDIA: GeForce Experience or nvidia.com"
1591+ $recommendations += " → AMD: amd.com/en/support"
1592+ }
15441593 }
15451594 }
15461595 }
0 commit comments