--- name: "pc-checkup" description: "Windows PC checkup and tune-up (проверка и настройка ПК): drivers, old-board leftovers, BIOS settings, fans and noise, lags, FACEIT readiness. Runs via a Cowork session linked to the PC. Speaks the user's language: if they write in Russian, everything is in Russian." --- # PC Checkup: auditing and tuning a Windows PC The full cycle: system audit → review → Windows cleanup and settings → drivers → BIOS → fans → checking the result in numbers. Claude collects the data from the PC itself; the user only runs scripts with a double click and does what can only be done by hand (BIOS, uninstalling programs in Settings). ## 0. Requirements — check them first - **Cowork, with the session linked to the user's computer.** The sign: the `mcp__remote-devices__*` tools are available. Call `get_device_info`; it should report `platform: win32`. - If it isn't linked: say briefly that they need to open the task in the Claude desktop app and choose "Link to this computer" (or start a new task with the computer selected). Until then, work in "I give you one PowerShell command at a time, you send me the output or a screenshot" mode. - **Folder access:** request `~/Desktop` with `device_request_folder_access` (reason: "I'll put a pc-audit folder with a diagnostics script there and read the report"). Check `device_list_dir ~/OneDrive` first: if the desktop has been moved into OneDrive, ask for `~/OneDrive/Desktop`. - **How commands actually run on Windows:** - Through computer use, terminals are available only in click mode (no typing), so commands are not entered through computer use. - `device_bash` is a Linux VM, not Windows. It may not start at all. It's useless for Windows commands. - The working scheme: write the files to `/mnt/user-data/outputs/pc-audit/`, put them on the PC with `device_commit_files`, the user runs the `.cmd` with a double click (the launcher asks for admin rights itself, the user clicks "Yes"), and you collect the result with `device_stage_files`. - Every `.ps1` is ASCII only (no Cyrillic), CRLF, compatible with Windows PowerShell 5.1. Before sending, check the syntax with portable PowerShell 7 in the container: download `powershell-7.x-linux-x64.tar.gz` from GitHub Releases into the scratchpad, then `[System.Management.Automation.Language.Parser]::ParseFile(...)`. ## 1. How to talk - In the user's language, short and to the point. If they have been writing in Russian, everything they read is in Russian — replies, questions, step lists, the report — even though this skill is written in English. Scripts stay ASCII English (see above). - Give steps one at a time or in batches of 3–6, with the exact path through the menus. Use Windows menu names in the system's language: check `OSLanguage` in the report (1033 = English). The names in this skill are the English ones. - Users often dictate by voice, so typos and swearing are normal. - **Any change to the system** (services, drivers, registry, uninstalling programs, settings, BIOS) only after an explicit "yes". Reading and checks need no permission. - When asked "why?", answer briefly: what it gives, what the downside is, how to roll it back. Respect the user's preferences: for example, "Enhance pointer precision" is a matter of habit, and if they're more comfortable with it on, turn it back on. - If the person is angry or tired: one sentence of sympathy, then straight to a concrete step. Admit your own mistakes plainly. If the work drags on, offer to stop and list what's already done. - Keep a task list: Audit → Review → Windows → Drivers → BIOS → Fans → Verify. ## 2. Getting started (one AskUserQuestion) Ask, unless it's clear from their message: - **Complaints:** lags, noise, crashes/blue screens, an anti-cheat is needed (FACEIT/Vanguard), low fps. - **What changed:** a new motherboard or CPU? Was Windows carried over from an old PC? - **Which software and peripherals they actually need:** for example, whether Armoury Crate is needed for an ASUS mouse, whether they use RGB lighting, a VPN, streaming. - **Games and benchmarks:** if they have baseline fps numbers (CS2 VProf: Avg/P1), ask for them, so there's something to compare against later. The audit will identify the hardware, so don't ask about it. ## 3. Audit (read-only) 1. Write `audit.ps1` and `run.cmd` (see "Scripts" below) to `/mnt/user-data/outputs/pc-audit/`, convert them to CRLF (`sed -i 's/\r*$/\r/'`), check the syntax. 2. Put them in `C:\Users\\Desktop\pc-audit\` with `device_commit_files`. 3. Ask the user to open the pc-audit folder on the desktop → double-click **run.cmd** → "Yes" → wait for DONE (1–2 minutes). Explain that the script only reads the system. 4. Poll: `sleep 60` → `device_list_dir ...\pc-audit\out` → once `done.txt` appears, collect `report.txt`, `nvidia-smi-q.txt`, `drivers-present-all.txt` and `ghost-devices-all.txt` with `device_stage_files`. 5. Clean up the output: `sed 's/\r$//; s/[[:space:]]*$//' | tr -d '\000' | sed 's/\xEF\xBB\xBF//' | cat -s | sed -E 's/ +/ /g'`. Find sections by `^=====` and read them in parts. 6. After each round of changes, ask them to run run.cmd again: that is how the result is checked. ## 4. Reviewing the report — checklist | What to look at | Where in the report | Normal / what to do | |---|---|---| | What's eating memory | Processes grouped, Memory | Less than 10% free or commit nearly exhausted → lags. Most often it's the browser: duplicate ad blockers, heavy extensions. In Firefox: about:addons, about:processes | | Page file | Memory, AutomaticManagedPagefile | A small fixed one → set it to automatic. Don't disable it | | Load at idle | CPU usage sample | Above 5–10% at idle → find the process | | EXPO/XMP | RAM modules: ConfiguredClockSpeed | Below the rated speed → enable the profile in BIOS | | SMT | NumberOfLogicalProcessors | Half the normal thread count → SMT is off. On Gigabyte that's **X3D Turbo Mode**: it gains a few % at most and is worse for multitasking | | Secure Boot / TPM / VBS / IOMMU | Secure Boot, VBS | For FACEIT: Secure Boot True, TPM 2.0, VBS=2, HVCI running, Available contains 3 (DMA/IOMMU). **Before enabling Secure Boot, check BitLocker**: if it's on, save the recovery key first | | Activation | Activation | After a motherboard change, LicenseStatus must be 1 | | BIOS version | Board/BIOS | Compare with the manufacturer's support site (WebFetch the support page). An old version → update it FIRST; the update resets all settings | | Graphics card bus | nvidia-smi, GPU Link Info | PCIe 4.0 riser → set Gen4 in BIOS. Gen5 through a Gen4 riser causes 0x116 blue screens (nvlddmkm) | | Monitors | Monitors | Refresh rate at maximum, the main one on DisplayPort (VideoOutputTechnology 10) | | Devices with errors | Devices with problems | Code 28 = no driver (often Wi-Fi/BT), code 31 = the driver won't load | | Ghosts of the old board | Ghost devices | Old CPU, PCI with the old vendor's SUBSYS (1043 = ASUS), old Wi-Fi/LAN → remove | | Driver store | Driver store | Old versions of the same INFs, drivers for hardware that's gone → delete without /force | | Old vendor leftovers | Services, Kernel drivers, Scheduled tasks, Programs, Store apps | Armoury Crate/AURA/ROG Live/AsIO3/IOMap and the like. Services that fail on every start add 30 s each to boot time | | iGPU with no monitor | GPU | If the integrated graphics is on with the Adrenalin driver while every monitor is on the discrete card: disable it in BIOS and uninstall AMD Software (keep the chipset driver) | | Power plan | Power | For Ryzen: Balanced + the Best performance power mode in Settings. High performance holds the clocks up at idle: more heat and noise for almost the same fps | | Fast startup | Power, Kernel-Boot 29 | Fast startup errors in the log, or the hardware changed → turn it off | | Gaming settings | Gaming-related | Game Mode on, HAGS on, Xbox background recording off, Enhance pointer precision up to the user | | Errors | WHEA, Crashes, Display driver resets | WHEA should be empty. 0x116 / nvlddmkm 153 → bus, riser, driver. Kernel-Power 41 → ask whether the PC was turned off with the power button | | Startup | Startup | Point out the heavy items, but the user decides | | Boot time | Boot time | For reference; compare before and after | **Clean install of Windows or keep the current one.** By default, keep the current one if it's activated and the leftovers can be cleaned. Suggest reinstalling only if the system is genuinely broken: reinstalling DAW plugins, a dev stack and games is days of work. ## 5. Report to the user - Start with the main cause of the complaint (for example: "Firefox is holding 31 of 32 GB"). - Then briefly: "what's already fine" and "what's wrong" (a numbered list, one line per item). - Put the decisions that are the user's to make into AskUserQuestion (multiSelect, up to 4 questions): what to clean, whether the vendor software is needed, whether to disable the iGPU, and so on. ## 6. Changes in Windows - With scripts: always **a restore point first** (template below), then the changes, then a log in `out\*-log.txt`. Collect the log and show the results. - Cleanup: - ghosts — `pnputil /remove-device `, only for non-present devices and only with clear signs of the old board; - old driver packages — `pnputil /delete-driver oemNN.inf` **without /force**: Windows itself won't let you delete a driver that's in use; - services — `sc.exe delete`, tasks — `Unregister-ScheduledTask`. - Remove vendor software with its official uninstaller. For ASUS that's the Armoury Crate Uninstall Tool: asus.com/supportonly/Armoury Crate/HelpDesk_Download, Driver & Utility tab. Clean up what's left with a script. - The user uninstalls ordinary programs themselves: Settings → Apps → Installed apps → "…" → Uninstall. Give them the exact list. - Settings (fast startup, page file, power plan, mouse acceleration) go in a separate script, and only after explaining them. The user sets the power mode in Settings themselves. ## 7. Drivers - The source is the board's Support page on the manufacturer's site (the right revision matters). Compare the versions in the report with the latest: chipset, LAN, Wi-Fi, Bluetooth, audio. Install only what's missing or outdated. - Graphics card — through the NVIDIA App or Adrenalin. Don't install utilities that update drivers on their own, or "optimizers". ## 8. BIOS (the user does it, Claude guides) **Order:** 1. **BIOS update** (if it's old). Unpack the file (not the zip) onto a FAT32 USB stick and plug it into a rear USB port. Gigabyte: F8 / Q-Flash → Update BIOS → file → Fast. ASUS: EZ Flash. MSI: M-Flash. Touch nothing while it flashes. If it asks about an fTPM reset, press N. 2. **First batch:** EXPO/XMP → profile 1 · PCIe x16 link speed → Gen4 (if the riser is Gen4) · Memory Context Restore → Enabled · Initial Display Output → PCIe 1 Slot · Integrated Graphics → Disabled (if the iGPU isn't needed) · SVM, IOMMU, fTPM → Enabled · CSM → Disabled · on Gigabyte also Utilities Downloader → Disabled. 3. **Second batch:** Secure Boot → Enabled (Standard; if there are no keys, Restore Factory Keys) · SMT → Enabled / X3D Turbo Mode → Disabled (optional; compare with a benchmark). 4. After each batch: F10 → boot → run.cmd → check. - On Gigabyte, search for a setting with **Alt+F**, switch to Advanced with **F2**, fans are on **F6**. - Don't touch PBO, Curve Optimizer or manual overclocking until the stability checks have passed. - New firmware may change some settings by itself (for example, enable Secure Boot or SMT). First check in the report what's already on, and only then give the list. ## 9. Fans and noise 1. Ask for an HWiNFO log: Sensors-only → the logging button (CSV) → 5–10 minutes of stress → stop. Analyse the CSV with the script below: the speed of each header at idle and under load, Tctl, throttling, PCIe errors, SSD/RAM/VRM/PCH temperatures. 2. Find the source: - a small fan on the M.2 / chipset heatsink (System 2 / PT_FAN, 6000–8000+ rpm) whines; - radiator fans at 1800+ rpm at idle — the curve is too aggressive; - a pump whose speed swings with the load. 3. Smart Fan (Gigabyte F6): Speed Control → Manual, Mode → Slope, Fan Stop → Disabled, Temperature Interval → maximum, Fail Warning → Enabled (for CPU_FAN, the pump, M.2; for a header with two fans it can be Disabled). - **Set the points from the last to the first**: a point can't move past its neighbour. - Sensor: CPU for the radiator, pump and case fans; PCH for the M.2/chipset fan. System1 and PCIe x16 barely change, so they're no good. 4. Reference curves (7 points, CPU temperature): - radiator: 20→25, 40→30, 55→35, 65→45, 72→60, 80→80, 85→100%; - pump: a flat 70% up to 72 °C, 80→85, 85→100%; - case fans: 20→30, 40→35, 55→40, 65→50, 72→60, 80→80, 85→100%; - M.2 on PCH: 25–40% up to 50 °C, 55→50, 60→70, 70→100%. 5. After tuning, another stress log: CPU no higher than 85 °C (89 is the limit on X3D), SSD no higher than 70 °C, PCH no higher than 65 °C. - Explain that a loud burst from the fans at power-on is normal: until the BIOS has loaded the curves, everything spins at 100%. ## 10. Checking the result - A final run.cmd: compare it with the first report in a "before → after" table. - A game benchmark with the same settings as the baseline (CS2: VProf at the same resolutions). The main thing to watch is the 1% low. - A blue screen or WHEA errors after the changes → go back to the last step. ## 11. Gotchas (from real experience) - **`shutdown /r /fw /t 0` → error 203:** the firmware won't let Windows boot into BIOS. There won't be a "UEFI Firmware Settings" item in the recovery menu either. That leaves Del. - **AM5, double start:** a blinking white bar = memory training. Pressing Del at that moment hangs the board. Press Del **after** the restart, often, 2–3 times a second. Memory Context Restore removes the training on every power-on. - **The keyboard isn't picked up before Windows:** a 4000–8000 Hz polling rate and NKRO → set it to 1000 Hz, plug it into a front port (the rear one loses power when training restarts) or use a simple wired one. Hung after Del → unplug every USB device except the keyboard. - **Black screen before Windows, but Windows itself is fine:** output before boot goes to only one connector. - iGPU enabled → the picture goes to the motherboard's HDMI (check by plugging a monitor in there). - RTX 50 + several monitors, or a monitor with DSC (for example, ASUS XG27AQDMG) → leave one DisplayPort on the graphics card, turn DSC off in the monitor's menu, put the main monitor on the first DP. - The last resort is the official NVIDIA GPU UEFI Firmware Update Tool. - A black screen after Del can mean the BIOS is open but not visible. To test: F10 → Enter. If the PC restarts, the BIOS was open. - **Can't get into BIOS, but it needs flashing:** Gigabyte Q-Flash Plus. Rename the file on a FAT32 stick to `GIGABYTE.bin` (turn on file name extensions), put the stick in the BIOS / Q-Flash Plus port, PC off but the power supply plugged in, press the button and wait until the light stops blinking (5–10 minutes). The flash resets the settings, display output included. - **Uninstalling AMD Software** rolls the iGPU back to the driver from Windows Update. The fix: disable the iGPU in BIOS, then clean up the packages. - **oemNN.inf numbers are reused** after deletion, so find packages by OriginalFileName and version, not by number. ## 12. Don'ts - Don't install optimizers, cleaners, driver auto-updaters or "tweaked" Windows builds. - Don't run scripts that mass-disable services. Explain: at idle, services cost ~0% load; the high fps in those videos comes from the hardware and low settings, and the real percentages there come from turning off VBS and other protections. With those off, FACEIT won't start. - Don't disable VBS, Memory integrity, Defender or the page file. - Don't change several groups of BIOS settings at once without a check in between. Don't touch overclocking until the stability checks. - Don't delete drivers with /force, and don't delete the chipset driver. ## Scripts ### run.cmd — launcher (for another script, change the .ps1 name) ```bat @echo off cd /d "%~dp0" net session >nul 2>&1 if %errorlevel% neq 0 ( powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" exit /b ) title PC audit (read-only) powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0audit.ps1" echo. echo Done. You can close this window. pause ``` ### audit.ps1 — audit (read-only, writes to .\out\) ```powershell # PC audit - READ-ONLY. Changes nothing. Writes reports to .\out\ $ErrorActionPreference = 'Continue' $ProgressPreference = 'SilentlyContinue' $base = Split-Path -Parent $MyInvocation.MyCommand.Path $out = Join-Path $base 'out' New-Item -ItemType Directory -Force -Path $out | Out-Null $R = Join-Path $out 'report.txt' Remove-Item (Join-Path $out 'done.txt') -ErrorAction SilentlyContinue Set-Content -Path $R -Value ("PC audit " + (Get-Date -Format 'yyyy-MM-dd HH:mm:ss')) -Encoding UTF8 function Sec { param([string]$Title, [scriptblock]$Body) Write-Host "-> $Title" Add-Content -Path $R -Value "`r`n===== $Title =====" -Encoding UTF8 try { $text = (& $Body 2>&1 | Out-String -Width 500) } catch { $text = "ERROR: $($_.Exception.Message)" } Add-Content -Path $R -Value $text -Encoding UTF8 } function Save { param([string]$Name, [scriptblock]$Body) Write-Host "-> $Name" $f = Join-Path $out $Name try { & $Body 2>&1 | Out-String -Width 600 | Set-Content -Path $f -Encoding UTF8 } catch { "ERROR: $($_.Exception.Message)" | Set-Content -Path $f -Encoding UTF8 } } function Get-Company([string]$path) { if (-not $path) { return $null } try { if (Test-Path -LiteralPath $path) { return (Get-Item -LiteralPath $path).VersionInfo.CompanyName } } catch {} return $null } function DDate($d) { if ($d) { try { return $d.ToString('yyyy-MM-dd') } catch { return "$d" } } } $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) Add-Content -Path $R -Value "Admin: $isAdmin" -Encoding UTF8 Sec 'Windows' { Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber, InstallDate, LastBootUpTime, OSLanguage | Format-List Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object DisplayVersion, EditionID, CurrentBuild, UBR | Format-List } Sec 'Activation (LicenseStatus 1 = activated)' { Get-CimInstance SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL AND ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f'" | Select-Object Name, Description, LicenseStatus | Format-List } Sec 'Board / BIOS / CPU' { Get-CimInstance Win32_BaseBoard | Select-Object Manufacturer, Product, Version | Format-List Get-CimInstance Win32_BIOS | Select-Object SMBIOSBIOSVersion, ReleaseDate | Format-List Get-CimInstance Win32_Processor | Select-Object Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed, VirtualizationFirmwareEnabled | Format-List Get-CimInstance Win32_ComputerSystem | Select-Object HypervisorPresent, AutomaticManagedPagefile | Format-List } Sec 'RAM modules (ConfiguredClockSpeed ~ rated = EXPO/XMP on)' { Get-CimInstance Win32_PhysicalMemory | Select-Object BankLabel, DeviceLocator, Manufacturer, PartNumber, @{n='GB';e={[int]($_.Capacity/1GB)}}, Speed, ConfiguredClockSpeed, ConfiguredVoltage | Format-Table -AutoSize } Sec 'Secure Boot / TPM / UEFI' { try { 'SecureBoot enabled: ' + (Confirm-SecureBootUEFI) } catch { 'SecureBoot: ' + $_.Exception.Message } 'SecureBoot state reg UEFISecureBootEnabled: ' + (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot\State' -ErrorAction SilentlyContinue).UEFISecureBootEnabled 'firmware_type env: ' + $env:firmware_type bcdedit /enum '{current}' | Select-String -Pattern 'path|hypervisor|nx' Get-Tpm | Select-Object TpmPresent, TpmReady, TpmEnabled, TpmActivated, ManufacturerIdTxt, ManufacturerVersion | Format-List Get-CimInstance -Namespace root\cimv2\Security\MicrosoftTpm -ClassName Win32_Tpm -ErrorAction SilentlyContinue | Select-Object SpecVersion | Format-List } Sec 'VBS / Memory integrity' { Get-CimInstance -Namespace root\Microsoft\Windows\DeviceGuard -ClassName Win32_DeviceGuard | Select-Object VirtualizationBasedSecurityStatus, @{n='Configured';e={$_.SecurityServicesConfigured -join ','}}, @{n='Running';e={$_.SecurityServicesRunning -join ','}}, @{n='Available';e={$_.AvailableSecurityProperties -join ','}}, @{n='Required';e={$_.RequiredSecurityProperties -join ','}} | Format-List 'Legend: VBS 0=off 1=enabled-not-running 2=running | Running 1=CredGuard 2=HVCI | Available 1=hypervisor 2=SecureBoot 3=DMA(IOMMU) 4=MemOverwrite 5=NX 6=SMM 7=MBEC' 'HVCI reg Enabled: ' + (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity' -ErrorAction SilentlyContinue).Enabled 'EnableVirtualizationBasedSecurity reg: ' + (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard' -ErrorAction SilentlyContinue).EnableVirtualizationBasedSecurity } Sec 'Windows optional features (virtualization)' { foreach ($f in 'Microsoft-Hyper-V-All','VirtualMachinePlatform','HypervisorPlatform','Microsoft-Windows-Subsystem-Linux','Containers-DisposableClientVM') { $x = Get-WindowsOptionalFeature -Online -FeatureName $f -ErrorAction SilentlyContinue if ($x) { '{0}: {1}' -f $f, $x.State } } } Sec 'BitLocker / device encryption' { Get-BitLockerVolume -ErrorAction Stop | Select-Object MountPoint, VolumeType, VolumeStatus, ProtectionStatus, EncryptionPercentage, @{n='Protectors';e={($_.KeyProtector | ForEach-Object { $_.KeyProtectorType }) -join ','}} | Format-Table -AutoSize } Sec 'Antivirus' { Get-CimInstance -Namespace root\SecurityCenter2 -ClassName AntiVirusProduct -ErrorAction SilentlyContinue | Select-Object displayName, productState | Format-Table -AutoSize Get-MpComputerStatus -ErrorAction SilentlyContinue | Select-Object AMServiceEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated | Format-List } Sec 'GPU' { Get-CimInstance Win32_VideoController | Select-Object Name, DriverVersion, DriverDate, CurrentHorizontalResolution, CurrentVerticalResolution, CurrentRefreshRate, MaxRefreshRate | Format-List $smi = Join-Path $env:SystemRoot 'System32\nvidia-smi.exe' if (Test-Path $smi) { & $smi --query-gpu=name,driver_version,pcie.link.gen.current,pcie.link.gen.max,pcie.link.width.current,pcie.link.width.max,temperature.gpu,fan.speed,utilization.gpu,power.draw,pstate --format=csv } else { 'nvidia-smi not found' } } Save 'nvidia-smi-q.txt' { $smi = Join-Path $env:SystemRoot 'System32\nvidia-smi.exe'; if (Test-Path $smi) { & $smi -q } } Sec 'Monitors' { Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorID -ErrorAction SilentlyContinue | ForEach-Object { $m = -join ($_.ManufacturerName | Where-Object { $_ -ne 0 } | ForEach-Object { [char]$_ }) $n = -join ($_.UserFriendlyName | Where-Object { $_ -ne 0 } | ForEach-Object { [char]$_ }) "$m $n [$($_.InstanceName)]" } Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorConnectionParams -ErrorAction SilentlyContinue | Select-Object InstanceName, VideoOutputTechnology | Format-Table -AutoSize 'VideoOutputTechnology: 5=HDMI 10=DisplayPort 4=DVI' $code = @' using System; using System.Runtime.InteropServices; public class DispInfoX { [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] public struct DEVMODE { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string dmDeviceName; public short dmSpecVersion; public short dmDriverVersion; public short dmSize; public short dmDriverExtra; public int dmFields; public int dmPositionX; public int dmPositionY; public int dmDisplayOrientation; public int dmDisplayFixedOutput; public short dmColor; public short dmDuplex; public short dmYResolution; public short dmTTOption; public short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string dmFormName; public short dmLogPixels; public int dmBitsPerPel; public int dmPelsWidth; public int dmPelsHeight; public int dmDisplayFlags; public int dmDisplayFrequency; public int dmICMMethod; public int dmICMIntent; public int dmMediaType; public int dmDitherType; public int dmReserved1; public int dmReserved2; public int dmPanningWidth; public int dmPanningHeight; } [DllImport("user32.dll", CharSet=CharSet.Ansi)] public static extern bool EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE devMode); public static string Get(string dev) { DEVMODE dm = new DEVMODE(); dm.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE)); string cur = "?"; if (EnumDisplaySettings(dev, -1, ref dm)) cur = dm.dmPelsWidth + "x" + dm.dmPelsHeight + " @ " + dm.dmDisplayFrequency + " Hz"; int maxSame = 0; int maxAny = 0; int i = 0; DEVMODE m = new DEVMODE(); m.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE)); while (EnumDisplaySettings(dev, i++, ref m)) { if (m.dmDisplayFrequency > maxAny) maxAny = m.dmDisplayFrequency; if (m.dmPelsWidth == dm.dmPelsWidth && m.dmPelsHeight == dm.dmPelsHeight && m.dmDisplayFrequency > maxSame) maxSame = m.dmDisplayFrequency; } return cur + " (max at this res: " + maxSame + " Hz, max any res: " + maxAny + " Hz)"; } } '@ try { Add-Type -TypeDefinition $code -ErrorAction Stop Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { '{0} primary={1}: {2}' -f $_.DeviceName, $_.Primary, [DispInfoX]::Get($_.DeviceName) } } catch { 'refresh check error: ' + $_.Exception.Message } } Sec 'Disks' { Get-PhysicalDisk | Select-Object DeviceId, FriendlyName, MediaType, BusType, HealthStatus, FirmwareVersion, @{n='GB';e={[int]($_.Size/1GB)}} | Format-Table -AutoSize Get-Disk | Select-Object Number, FriendlyName, PartitionStyle, IsBoot, IsSystem, @{n='GB';e={[int]($_.Size/1GB)}} | Format-Table -AutoSize Get-Partition | Select-Object DiskNumber, PartitionNumber, DriveLetter, Type, IsBoot, IsSystem, @{n='GB';e={[math]::Round($_.Size/1GB,1)}} | Format-Table -AutoSize Get-Volume | Where-Object DriveLetter | Select-Object DriveLetter, FileSystemLabel, FileSystem, @{n='SizeGB';e={[int]($_.Size/1GB)}}, @{n='FreeGB';e={[int]($_.SizeRemaining/1GB)}} | Format-Table -AutoSize Get-PhysicalDisk | Get-StorageReliabilityCounter -ErrorAction SilentlyContinue | Select-Object DeviceId, Temperature, TemperatureMax, Wear, ReadErrorsTotal, WriteErrorsTotal, PowerOnHours | Format-Table -AutoSize bcdedit /enum firmware | Select-String -Pattern 'description|device|path' } Sec 'Memory' { $os = Get-CimInstance Win32_OperatingSystem 'RAM total {0:N1} GB, free {1:N1} GB; commit limit {2:N1} GB, commit free {3:N1} GB' -f ($os.TotalVisibleMemorySize/1MB), ($os.FreePhysicalMemory/1MB), ($os.TotalVirtualMemorySize/1MB), ($os.FreeVirtualMemory/1MB) Get-CimInstance Win32_PageFileUsage | Select-Object Name, AllocatedBaseSize, CurrentUsage, PeakUsage | Format-Table -AutoSize Get-CimInstance Win32_PageFileSetting | Select-Object Name, InitialSize, MaximumSize | Format-Table -AutoSize try { Get-MMAgent | Select-Object MemoryCompression, PageCombining, ApplicationPreLaunch | Format-List } catch {} } Sec 'Processes grouped by memory (top 30)' { "process count: $((Get-Process).Count)" Get-Process | Group-Object Name | ForEach-Object { [pscustomobject]@{ Name=$_.Name; Count=$_.Count; Private_MB=[int](($_.Group | Measure-Object PrivateMemorySize64 -Sum).Sum/1MB); WS_MB=[int](($_.Group | Measure-Object WorkingSet64 -Sum).Sum/1MB) } } | Sort-Object Private_MB -Descending | Select-Object -First 30 | Format-Table -AutoSize } Sec 'CPU usage sample over 5 s (top 15, % of whole CPU)' { $n = [Environment]::ProcessorCount $a = @{} Get-Process | ForEach-Object { if ($_.CPU -ne $null) { $a[$_.Id] = $_.CPU } } Start-Sleep -Seconds 5 Get-Process | ForEach-Object { if ($_.CPU -ne $null -and $a.ContainsKey($_.Id)) { [pscustomobject]@{ Name=$_.Name; Id=$_.Id; CPU_pct=[math]::Round(($_.CPU - $a[$_.Id]) / 5 / $n * 100, 1) } } } | Sort-Object CPU_pct -Descending | Select-Object -First 15 | Format-Table -AutoSize } Sec 'Browsers' { foreach ($b in 'firefox','chrome','msedge','opera','brave') { $p = @(Get-Process $b -ErrorAction SilentlyContinue) if ($p.Count -gt 0) { '{0}: processes {1}, private MB {2}' -f $b, $p.Count, [int](($p | Measure-Object PrivateMemorySize64 -Sum).Sum/1MB) } } $profRoot = Join-Path $env:APPDATA 'Mozilla\Firefox\Profiles' Get-ChildItem $profRoot -Directory -ErrorAction SilentlyContinue | ForEach-Object { "Firefox profile: $($_.Name)" $ej = Join-Path $_.FullName 'extensions.json' if (Test-Path $ej) { try { $j = Get-Content $ej -Raw -Encoding UTF8 | ConvertFrom-Json $j.addons | Where-Object { $_.type -eq 'extension' -and $_.location -eq 'app-profile' } | ForEach-Object { $st = 'off'; if ($_.active) { $st = 'on' } " ext: $($_.defaultLocale.name) [$st]" } } catch { ' ext read error' } } } } Sec 'Devices with problems (ConfigManagerErrorCode != 0)' { Get-CimInstance Win32_PnPEntity | Where-Object { $_.ConfigManagerErrorCode -ne 0 } | Select-Object Name, PNPClass, ConfigManagerErrorCode, DeviceID | Format-Table -AutoSize } $drv = @(Get-CimInstance Win32_PnPSignedDriver) Sec 'Active drivers, non-Microsoft (present devices)' { $drv | Where-Object { $_.DriverProviderName -and $_.DriverProviderName -notmatch '^Microsoft' } | Select-Object DeviceClass, DeviceName, DriverProviderName, DriverVersion, @{n='Date';e={ DDate $_.DriverDate }}, InfName | Sort-Object DeviceClass, DeviceName | Format-Table -AutoSize } Sec 'Chipset platform devices (AMD/Intel)' { $drv | Where-Object { $_.DeviceName -match 'AMD|Ryzen|PSP|GPIO|SMBus|I2C|V-Cache|PPM|Intel|Management Engine|Serial IO' -or $_.HardWareID -match 'VEN_1022|AMDI|VEN_8086' } | Select-Object DeviceName, DriverProviderName, DriverVersion, @{n='Date';e={ DDate $_.DriverDate }}, InfName | Sort-Object DeviceName | Format-Table -AutoSize } Save 'drivers-present-all.txt' { $drv | Select-Object DeviceClass, DeviceName, DriverProviderName, DriverVersion, @{n='Date';e={ DDate $_.DriverDate }}, InfName, HardWareID | Sort-Object DeviceClass, DeviceName | Format-Table -AutoSize } $ghost = @(Get-PnpDevice -ErrorAction SilentlyContinue | Where-Object { -not $_.Present }) Sec 'Ghost (non-present) devices by class' { "total ghost devices: $($ghost.Count)" $ghost | Group-Object Class | Sort-Object Count -Descending | Select-Object Count, Name | Format-Table -AutoSize } Sec 'Ghost devices: PCI / ACPI / HDAUDIO / ROOT / System / Net / Display / Media' { $ghost | Where-Object { $_.InstanceId -match '^(PCI|ACPI|HDAUDIO|ROOT|SWC)' -or $_.Class -match '^(System|Net|Display|MEDIA|HDC|SCSIAdapter|Bluetooth|Extension|SoftwareComponent|Processor)$' } | Select-Object Class, FriendlyName, Manufacturer, InstanceId | Sort-Object Class, FriendlyName | Format-Table -AutoSize } Save 'ghost-devices-all.txt' { $ghost | Select-Object Class, FriendlyName, Manufacturer, InstanceId | Sort-Object Class, FriendlyName | Format-Table -AutoSize } Sec 'Driver store: third-party packages (Get-WindowsDriver)' { Get-WindowsDriver -Online -ErrorAction Stop | Select-Object Driver, @{n='Orig';e={ Split-Path $_.OriginalFileName -Leaf }}, ProviderName, ClassName, Version, @{n='Date';e={ DDate $_.Date }} | Sort-Object ProviderName, Orig, Version | Format-Table -AutoSize } Sec 'Kernel drivers, non-Microsoft' { Get-CimInstance Win32_SystemDriver | ForEach-Object { $p = $_.PathName if ($p) { $p = $p -replace '^\\\?\?\\', '' $p = $p -replace '^\\SystemRoot', $env:SystemRoot if ($p -match '^system32') { $p = Join-Path $env:SystemRoot $p } } [pscustomobject]@{ Name=$_.Name; Display=$_.DisplayName; Start=$_.StartMode; State=$_.State; Company=(Get-Company $p); Path=$p } } | Where-Object { $_.Company -notmatch 'Microsoft' } | Sort-Object Company, Name | Format-Table -AutoSize } Sec 'Services, non-Microsoft' { Get-CimInstance Win32_Service | ForEach-Object { $exe = $null; $pn = $_.PathName if ($pn -match '^\s*"([^"]+)"') { $exe = $Matches[1] } elseif ($pn -match '^\s*(.+?\.exe)') { $exe = $Matches[1] } [pscustomobject]@{ Name=$_.Name; Display=$_.DisplayName; Start=$_.StartMode; State=$_.State; Company=(Get-Company $exe); Exe=$exe } } | Where-Object { $_.Company -notmatch 'Microsoft' } | Sort-Object Company, Name | Format-Table -AutoSize } Sec 'Scheduled tasks, non-Microsoft' { Get-ScheduledTask | Where-Object { $_.TaskPath -notlike '\Microsoft\*' } | ForEach-Object { $act = ($_.Actions | ForEach-Object { ('' + $_.Execute + ' ' + $_.Arguments).Trim() }) -join ' | ' [pscustomobject]@{ Path=$_.TaskPath; Name=$_.TaskName; State=$_.State; Action=$act } } | Sort-Object Path, Name | Format-Table -AutoSize } Sec 'Startup entries' { Get-CimInstance Win32_StartupCommand | Select-Object Name, Command, Location | Format-Table -AutoSize } Sec 'Startup on/off state (Task Manager)' { $keys = @( 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run', 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder', 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run', 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run32', 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\StartupFolder') $rows = @() foreach ($k in $keys) { if (Test-Path $k) { $item = Get-Item $k foreach ($v in $item.Property) { $b = $item.GetValue($v) $en = 'on'; if ($b -and ($b[0] % 2) -eq 1) { $en = 'off' } $rows += [pscustomobject]@{ Hive=$k.Substring(0,4); Key=(Split-Path $k -Leaf); Name=$v; State=$en } } } } $rows | Format-Table -AutoSize } Sec 'Installed programs' { Get-ItemProperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and $_.SystemComponent -ne 1 -and -not $_.ParentKeyName } | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Sort-Object DisplayName -Unique | Format-Table -AutoSize } Sec 'Store apps, non-Microsoft' { Get-AppxPackage -AllUsers -ErrorAction SilentlyContinue | Where-Object { -not $_.IsFramework -and $_.Publisher -notmatch 'O=Microsoft Corporation' } | Select-Object Name, Version | Sort-Object Name -Unique | Format-Table -AutoSize } Sec 'Power' { powercfg /getactivescheme powercfg /list 'Fast startup HiberbootEnabled: ' + (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -ErrorAction SilentlyContinue).HiberbootEnabled powercfg /a } Sec 'Gaming-related settings' { 'HAGS HwSchMode (2=on, 1=off, empty=default): ' + (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers' -ErrorAction SilentlyContinue).HwSchMode 'Game Mode AutoGameModeEnabled (empty or 1 = on): ' + (Get-ItemProperty 'HKCU:\Software\Microsoft\GameBar' -ErrorAction SilentlyContinue).AutoGameModeEnabled 'Game DVR HistoricalCaptureEnabled: ' + (Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR' -ErrorAction SilentlyContinue).HistoricalCaptureEnabled 'GameConfigStore GameDVR_Enabled: ' + (Get-ItemProperty 'HKCU:\System\GameConfigStore' -ErrorAction SilentlyContinue).GameDVR_Enabled Get-ItemProperty 'HKCU:\Control Panel\Mouse' | Select-Object MouseSpeed, MouseThreshold1, MouseThreshold2, MouseSensitivity | Format-List 'MouseSpeed 1 = Enhance pointer precision ON, 0 = OFF' } Sec 'Last updates' { Get-HotFix -ErrorAction SilentlyContinue | Sort-Object InstalledOn -Descending | Select-Object -First 6 HotFixID, Description, InstalledOn | Format-Table -AutoSize } Sec 'Network adapters' { Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, LinkSpeed, DriverVersion, DriverDate, DriverProvider | Format-Table -AutoSize } Sec 'Audio devices' { Get-CimInstance Win32_SoundDevice | Select-Object Name, Manufacturer, Status | Format-Table -AutoSize } Sec 'WHEA hardware errors' { $e = Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='Microsoft-Windows-WHEA-Logger'} -MaxEvents 20 -ErrorAction SilentlyContinue if ($e) { $e | Select-Object TimeCreated, Id, LevelDisplayName, Message | Format-List } else { 'none' } } Sec 'Crashes / unexpected shutdowns (41, 1001, 6008), last 30 days' { $e = Get-WinEvent -FilterHashtable @{LogName='System'; Id=41,1001,6008; StartTime=(Get-Date).AddDays(-30)} -ErrorAction SilentlyContinue if ($e) { $e | Select-Object TimeCreated, Id, ProviderName | Format-Table -AutoSize } else { 'none' } } Sec 'Display driver resets (nvlddmkm / Display / amdkmdag)' { $e = Get-WinEvent -FilterHashtable @{LogName='System'; ProviderName='nvlddmkm','Display','amdkmdag'} -MaxEvents 15 -ErrorAction SilentlyContinue if ($e) { $e | Select-Object TimeCreated, ProviderName, Id | Format-Table -AutoSize } else { 'none' } } foreach ($log in 'System','Application') { Sec "$log log errors, last 7 days, grouped" { Get-WinEvent -FilterHashtable @{LogName=$log; Level=1,2; StartTime=(Get-Date).AddDays(-7)} -ErrorAction SilentlyContinue | Group-Object ProviderName, Id | Sort-Object Count -Descending | Select-Object -First 30 Count, Name, @{n='Last';e={$_.Group[0].TimeCreated}}, @{n='Msg';e={ $m = $_.Group[0].Message; if ($m) { $l = ($m -split "`r?`n")[0]; $l.Substring(0, [Math]::Min(220, $l.Length)) } }} | Format-Table -AutoSize -Wrap } } Sec 'Boot time (last 5 boots, ms)' { Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-Diagnostics-Performance/Operational'; Id=100} -MaxEvents 5 -ErrorAction SilentlyContinue | ForEach-Object { $x = [xml]$_.ToXml() [pscustomobject]@{ Time=$_.TimeCreated; BootMs=($x.Event.EventData.Data | Where-Object Name -eq 'BootTime').'#text'; MainPathMs=($x.Event.EventData.Data | Where-Object Name -eq 'MainPathBootTime').'#text'; PostBootMs=($x.Event.EventData.Data | Where-Object Name -eq 'BootPostBootTime').'#text' } } | Format-Table -AutoSize } Set-Content -Path (Join-Path $out 'done.txt') -Value (Get-Date -Format s) Write-Host '' Write-Host 'DONE. Report: out\report.txt' -ForegroundColor Green ``` ### Change script template (restore point + cleanup + log) Fill in the actual lists from the report. Find driver packages by `OriginalFileName` and version. ```powershell $ErrorActionPreference = 'Continue' $base = Split-Path -Parent $MyInvocation.MyCommand.Path $out = Join-Path $base 'out'; New-Item -ItemType Directory -Force -Path $out | Out-Null $L = Join-Path $out 'cleanup-log.txt' Set-Content -Path $L -Value ("cleanup " + (Get-Date -Format s)) -Encoding UTF8 function Log([string]$m) { Write-Host $m; Add-Content -Path $L -Value $m -Encoding UTF8 } # 1) restore point (bypass 24h limit temporarily); ask before continuing if it fails $rpOk = $false try { Enable-ComputerRestore -Drive "$env:SystemDrive\" -ErrorAction Stop $k = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore' $old = (Get-ItemProperty $k -ErrorAction SilentlyContinue).SystemRestorePointCreationFrequency New-ItemProperty -Path $k -Name SystemRestorePointCreationFrequency -Value 0 -PropertyType DWord -Force | Out-Null $before = @(Get-ComputerRestorePoint -ErrorAction SilentlyContinue).Count Checkpoint-Computer -Description 'Before cleanup' -RestorePointType MODIFY_SETTINGS -ErrorAction Stop if ($old -ne $null) { Set-ItemProperty -Path $k -Name SystemRestorePointCreationFrequency -Value $old } else { Remove-ItemProperty -Path $k -Name SystemRestorePointCreationFrequency -ErrorAction SilentlyContinue } if (@(Get-ComputerRestorePoint -ErrorAction SilentlyContinue).Count -gt $before) { $rpOk = $true; Log 'restore point OK' } } catch { Log ("restore point FAILED: " + $_.Exception.Message) } if (-not $rpOk) { if ((Read-Host 'Restore point NOT created. Continue? (y/n)') -ne 'y') { exit 1 } } # 2) ghost devices of the old platform (adjust the filter to what the audit showed) Get-PnpDevice | Where-Object { -not $_.Present -and ($_.InstanceId -match '^(PCI|ACPI|HDAUDIO|BTH|BTHENUM|BTHLE|BTHLEDEVICE|BTHHFENUM|UEFI)\\') } | ForEach-Object { $null = pnputil /remove-device "$($_.InstanceId)" 2>&1; Log ("ghost {0}: {1}" -f $LASTEXITCODE, $_.FriendlyName) } # 3) outdated driver packages: list of @(original inf, version or '*'); never /force $remove = @( @('example.inf','1.0.0.0') ) $store = @(Get-WindowsDriver -Online -ErrorAction SilentlyContinue) foreach ($r in $remove) { $store | Where-Object { (Split-Path $_.OriginalFileName -Leaf) -eq $r[0] -and ($r[1] -eq '*' -or $_.Version -eq $r[1]) } | ForEach-Object { $null = pnputil /delete-driver $_.Driver 2>&1 $st = 'KEPT (in use)'; if ($LASTEXITCODE -eq 0) { $st = 'deleted' } Log ("{0} | {1} {2} {3}" -f $st, $_.Driver, $r[0], $_.Version) } } Set-Content -Path (Join-Path $out 'cleanup-done.txt') -Value (Get-Date -Format s) ``` ### Parsing the HWiNFO CSV log (Python in the container, `python3 -I`) ```python import csv, sys, statistics as st r = list(csv.reader(open(sys.argv[1], encoding='latin-1', newline=''))) h = r[0]; rows = [x for x in r[1:] if x and x[0][:1].isdigit()] def idx(name, nth=0): ii = [i for i, c in enumerate(h) if c == name]; return ii[nth] if len(ii) > nth else None def col(i): out = [] for x in rows: try: out.append(float(x[i])) except: out.append(None) return out usage = col(idx('Total CPU Usage [%]')) load = [i for i, u in enumerate(usage) if u is not None and u > 90] idle = [i for i, u in enumerate(usage) if u is not None and u < 15] names = ['CPU (Tctl/Tdie) [°C]', 'Core Effective Clocks (avg) [MHz]', 'CPU Package Power [W]', 'Thermal Throttling (HTC) [Yes/No]', 'Memory Clock [MHz]', 'Infinity Fabric Clock (FCLK) [MHz]', 'CPU VCORE SoC [V]', 'VRM MOS [°C]', 'PCH [°C]', 'CPU [RPM]', 'CPU_OPT [RPM]', 'System 1 [RPM]', 'System 2 [RPM]', 'GPU Temperature [°C]', 'GPU Fan1 [RPM]', 'PCIe Link Speed [GT/s]', 'Correctable Error Count []', 'Drive Temperature [°C]', 'SPD Hub Temperature [°C]'] for sel, label in ((load, 'LOAD'), (idle, 'IDLE')): print('==', label, len(sel), 'rows') for n in names: i = idx(n) if i is None: continue v = [col(i)[k] for k in sel if col(i)[k] is not None] if v: print(f' {n}: min {min(v):.1f} avg {st.mean(v):.1f} max {max(v):.1f}') ``` Reference values for a 7800X3D: under full load, Tctl at 70–80 °C is normal (the limit is 89), about 4.5 GHz on all cores and about 88 W. The graphics card on Gen4 with no PCIe errors. SoC up to 1.3 V.