# Focused memory / WHEA confirmation for DESKTOP-BTR2AM3
$ErrorActionPreference = 'SilentlyContinue'
function H($t){ "`n===== $t =====" }

H "WINDOWS MEMORY DIAGNOSTIC RESULTS"
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-MemoryDiagnostics-Results'} -MaxEvents 10 |
  Select-Object TimeCreated, Id, LevelDisplayName, Message | Format-List | Out-String

H "WHEA EVENT 47 - FULL DETAIL (most recent 5)"
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-WHEA-Logger'; Id=47} -MaxEvents 5 |
  ForEach-Object { "--- $($_.TimeCreated) ---"; $_.Message } | Out-String

H "WHEA EVENT 47 - COUNT BY DAY (last 30d)"
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-WHEA-Logger'; StartTime=(Get-Date).AddDays(-30)} |
  Group-Object {$_.TimeCreated.Date}, Id | Sort-Object Name | Select-Object Count, Name | Format-Table -Auto | Out-String

H "WHEA ALL IDs SEEN (last 30d)"
Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-WHEA-Logger'; StartTime=(Get-Date).AddDays(-30)} |
  Group-Object Id, LevelDisplayName | Select-Object Count, Name | Format-Table -Auto | Out-String

H "MEMORY CONFIG"
Get-CimInstance Win32_OperatingSystem | Select-Object @{n='FreePhysMB';e={[int]($_.FreePhysicalMemory/1KB)}}, @{n='TotalVisibleMB';e={[int]($_.TotalVisibleMemorySize/1KB)}} | Format-List | Out-String
"Top RAM consumers:"
Get-Process | Sort-Object WS -Desc | Select-Object -First 8 Name, @{n='WS_MB';e={[int]($_.WS/1MB)}} | Format-Table -Auto | Out-String

H "SCHEDULED MEMORY TEST PENDING?"
bcdedit /enum '{memdiag}' 2>&1 | Out-String

H "DONE"
