diff --git a/apps/systeminfo.ps1 b/apps/systeminfo.ps1 index b96ff9d..a258671 100644 --- a/apps/systeminfo.ps1 +++ b/apps/systeminfo.ps1 @@ -1005,7 +1005,9 @@ $LagSections = @( $v = & $avg '\PhysicalDisk(_Total)\Avg. Disk Queue Length'; if ($v -ge 2) { Add-Flag "Disk queue length averages $([math]::Round($v, 1)) while idle: the disk is the bottleneck." } $v = & $avg '\PhysicalDisk(_Total)\% Idle Time'; if ($null -ne $v -and $v -lt 50) { Add-Flag "Disk is busy $([math]::Round(100 - $v)) % of the time while idle." } $v = & $avg '\Memory\Pool Nonpaged Bytes'; if ($v -ge 1.5GB) { Add-Flag "Nonpaged pool is $([math]::Round($v / 1GB, 1)) GB: a driver is leaking kernel memory." } - $v = & $avg '\Process(_Total)\Handle Count'; if ($v -ge 150000) { Add-Flag "$([math]::Round($v)) handles open system-wide: a process is leaking handles." } + $v = & $avg '\Process(_Total)\Handle Count'; $pc = @(Get-Process).Count + # Busy managed PCs run 400+ processes at ~500 handles each; only a high average points at a leak + if ($v -ge 150000 -and $pc -and ($v / $pc) -ge 1000) { Add-Flag "$([math]::Round($v)) handles open system-wide ($([math]::Round($v / $pc)) per process): a process is leaking handles." } }, 'PROCESSES (5 S SAMPLE)', { @@ -1051,7 +1053,8 @@ $LagSections = @( } else { Add-Flag "explorer.exe is not running." } $hog = $rows | Where-Object { $_.'CPU%' -ge 25 } | Sort-Object 'CPU%' -Descending foreach ($h in $hog) { Add-Flag "$($h.Name) (PID $($h.PID), $($h.Company)) used $($h.'CPU%') % CPU during the idle sample." } - $nr = $rows | Where-Object Responding -eq 'NO' + # Suspended Settings / Store-app frames report not responding while in the background + $nr = $rows | Where-Object { $_.Responding -eq 'NO' -and $_.Name -notin 'SystemSettings', 'ApplicationFrameHost' } foreach ($n in $nr) { Add-Flag "Window of $($n.Name) (PID $($n.PID)) is NOT RESPONDING right now." } Sub "Services inside the busiest svchost processes" $svc = Get-CimInstance Win32_Service @@ -1400,8 +1403,9 @@ $a = 0; $b = 0; $d = 0; $c.NumberOfItemsToIndex([ref]$a, [ref]$b, [ref]$d) 'DRIVERS AND DEVICES', { Sub "Devices with problems" - $bad = Get-PnpDevice -ErrorAction SilentlyContinue | Where-Object { $_.Status -ne 'OK' -and $_.Present } - if ($bad) { OrNone ($bad | Select-Object FriendlyName, Status, Class, @{n = 'Problem'; e = { $_.ProblemDescription }} | Format-Table -AutoSize); foreach ($b in $bad) { Add-Flag "Device problem: $($b.FriendlyName) ($($b.Class)) status $($b.Status)." } } + # 'Degraded' devices with no error code work normally; code 22 is disabled on purpose + $bad = @(Get-ProblemDevices | Where-Object ConfigManagerErrorCode -ne 22) + if ($bad) { OrNone ($bad | Select-Object Name, PNPClass, @{ n = 'Problem'; e = { $c = [int]$_.ConfigManagerErrorCode; "$c $($DevCodes[$c])" } } | Format-Table -AutoSize); foreach ($b in $bad) { Add-Flag "Device problem: $($b.Name) ($($b.PNPClass)) error code $($b.ConfigManagerErrorCode)." } } else { 'None.' } Sub "Display, storage, network, chipset drivers" $drv = Get-CimInstance Win32_PnPSignedDriver | Where-Object { $_.DeviceName -and $_.DeviceClass -in 'DISPLAY', 'NET', 'HDC', 'SCSIADAPTER', 'DISKDRIVE', 'MEDIA', 'BLUETOOTH', 'SYSTEM' } @@ -1509,20 +1513,24 @@ $a = 0; $b = 0; $d = 0; $c.NumberOfItemsToIndex([ref]$a, [ref]$b, [ref]$d) $shellHang = $hangs | Where-Object { "$($_.Properties[0].Value)" -match '^(explorer|SearchHost|SearchApp|StartMenuExperienceHost|ShellExperienceHost|dwm)\.exe' } if ($shellHang) { Add-Flag "$(@($shellHang).Count) hang/crash events for the shell ($(($shellHang | ForEach-Object { "$($_.Properties[0].Value)" } | Sort-Object -Unique) -join ', ')) in 14 days." } - Sub "Disk / storage events, last 30 days (7, 11, 51, 55, 98, 129, 153, 157 = bad sectors, resets, NTFS damage)" - $disk = @(Get-Events @{ LogName = 'System'; Id = 7, 11, 51, 55, 98, 129, 153, 157, 140; StartTime = (Get-Date).AddDays(-30) } 40) - OrNone ($disk | Select-Object TimeCreated, Id, ProviderName, @{n = 'Message'; e = { Short $_.Message 200 } } | Format-Table -AutoSize -Wrap) - if ($disk | Where-Object { $_.ProviderName -match 'disk|ntfs|stor|volmgr|nvme|iaStor|partmgr' }) { Add-Flag "$(@($disk).Count) storage error events in 30 days (IDs $(($disk | ForEach-Object Id | Sort-Object -Unique) -join ',')). The disk or its cable/driver is faulty." } + Sub "Disk / storage warnings and errors, last 30 days (7, 11, 51, 55, 98, 129, 153, 157 = bad sectors, resets, NTFS damage)" + # The same IDs are used by unrelated providers (filter manager, hypervisor, CPU power), so keep storage ones only + $disk = @(Get-Events @{ LogName = 'System'; Id = 7, 11, 51, 55, 98, 129, 140, 153, 157; Level = 1, 2, 3; StartTime = (Get-Date).AddDays(-30) } 200 | + Where-Object { $_.ProviderName -match '^(disk|Ntfs|Microsoft-Windows-Ntfs|volmgr|partmgr|Microsoft-Windows-StorPort)$|^(stor|iaStor)|nvme' }) + OrNone ($disk | Select-Object -First 40 TimeCreated, Id, ProviderName, @{n = 'Message'; e = { Short $_.Message 200 } } | Format-Table -AutoSize -Wrap) + if ($disk) { Add-Flag "$($disk.Count) storage warning/error events in 30 days (IDs $(($disk | ForEach-Object Id | Sort-Object -Unique) -join ',')). The disk or its cable/driver is faulty." } - Sub "Hardware errors (WHEA), last 30 days" - $whea = @(Get-Events @{ LogName = 'System'; ProviderName = 'Microsoft-Windows-WHEA-Logger'; StartTime = (Get-Date).AddDays(-30) } 20) + Sub "Hardware errors (WHEA warnings and errors), last 30 days" + $whea = @(Get-Events @{ LogName = 'System'; ProviderName = 'Microsoft-Windows-WHEA-Logger'; Level = 1, 2, 3; StartTime = (Get-Date).AddDays(-30) } 20) OrNone ($whea | Select-Object TimeCreated, Id, LevelDisplayName, @{n = 'Message'; e = { Short $_.Message 200 } } | Format-Table -AutoSize -Wrap) if ($whea) { Add-Flag "$($whea.Count) WHEA hardware error events in 30 days (CPU, memory, PCIe or firmware fault)." } Sub "Unexpected shutdowns / crashes (41, 6008, 1001), last 30 days" $crash = @(Get-Events @{ LogName = 'System'; Id = 41, 6008, 1001; StartTime = (Get-Date).AddDays(-30) } 20) OrNone ($crash | Select-Object TimeCreated, Id, ProviderName, @{n = 'Message'; e = { Short $_.Message 160 } } | Format-Table -AutoSize -Wrap) - if ($crash | Where-Object { $_.Id -in 41, 6008 }) { Add-Flag "$(@($crash | Where-Object { $_.Id -in 41, 6008 }).Count) unexpected shutdowns / blue screens in 30 days." } + # Events 41 and 6008 are logged in pairs for one incident + $n = [math]::Max(@($crash | Where-Object Id -eq 41).Count, @($crash | Where-Object Id -eq 6008).Count) + if ($n) { Add-Flag "$n unexpected shutdowns / blue screens in 30 days." } Sub "Diagnostics-Performance, last 14 days (1xx boot, 2xx shutdown, 3xx standby, 4xx desktop responsiveness, 5xx Explorer)" $perf = @(Get-Events @{ LogName = 'Microsoft-Windows-Diagnostics-Performance/Operational'; StartTime = (Get-Date).AddDays(-14) } 300)