Diagnose a misbehaving Windows PC with built-in PowerShell commands

diagnose a misbehaving windows pc with built in powershell commands A Windows PC that freezes, loses its battery charge overnight or reboots without warning can often be checked with a handful of PowerShell commands that ship with the system, before any money goes to a repair shop. These commands report storage reliability counters, battery capacity, activity during standby, unexpected shutdowns and corruption in system files. No single one covers every fault. Used together, they turn a vague complaint into a specific problem you can look into.Image Source: HowtogeekimagesImage Source: Howtogeekimages

A Windows PC that freezes, loses its battery charge overnight or reboots without warning can often be checked with a handful of PowerShell commands that ship with the system, before any money goes to a repair shop. These commands report storage reliability counters, battery capacity, activity during standby, unexpected shutdowns and corruption in system files. No single one covers every fault. Used together, they turn a vague complaint into a specific problem you can look into.

Every command in this guide needs PowerShell running as administrator.

Check how healthy and worn your drive is

When the PC hangs as you open files or move folders, the storage drive is a likelier culprit than Windows. The two commands below list your disks and read their reliability counters.

  1. Open PowerShell as administrator.
  2. List your disks and their health status with this command:
    Get-PhysicalDisk | Select-Object DeviceId, FriendlyName, HealthStatus
  3. Read the reliability counters for each disk with this command:
    Get-PhysicalDisk | Get-StorageReliabilityCounter | Select-Object DeviceId, Temperature, Wear, PowerOnHours, ReadErrorsUncorrected, WriteErrorsUncorrected
  4. Line up the DeviceId values in both outputs so you know which drive each row refers to.

Reading the output

Temperature gives the drive’s current temperature in Celsius. Check it against the operating range listed in the manufacturer’s specifications instead of guessing whether the figure is acceptable.

Wear is the figure to watch on an SSD. It shows how much of the estimated wear has already been used, not how much life remains, and a value of 100 means the drive has hit its estimated wear limit. If yours is close to 100, back up your files first.

ReadErrorsUncorrected and WriteErrorsUncorrected count the errors the drive was unable to correct by itself.

Empty fields are no sign of a healthy drive. Certain drives, controllers and connection paths simply don’t report these values. A Healthy status is the storage provider’s judgment, and it doesn’t prove the drive is flawless. If the computer keeps freezing or files turn unreadable on their own, consider replacing the SSD.

Create a battery report to measure lost capacity

When a laptop’s battery percentage falls faster than it once did, a battery report shows whether the battery itself has lost capacity.

  1. Open PowerShell as administrator.
  2. Run this command:
    powercfg /batteryreport /output "$env:USERPROFILE\battery-report.html"
  3. Open battery-report.html from your user profile folder in a web browser.
  4. Go to the Installed batteries section.
  5. Compare the Full charge capacity figure with the Design capacity figure.

Full charge capacity is the maximum the battery can store now. Design capacity is what it was built to store when it was new. A wide gap between them means battery wear explains the shorter runtime, even if Windows reports a full charge.

The report also carries a battery capacity history, so you can see whether capacity has dropped over time instead of relying on a single reading. Its battery life estimates come from your recorded usage, so treat them as context and not a guarantee of runtime. This report is the fastest way to separate lost capacity from heavier power draw.

Track down battery drain during Modern Standby

Laptops with Modern Standby can go to sleep on a full charge and wake up the next day almost flat. A SleepStudy report shows what stayed active during sleep.

  1. Open PowerShell as administrator.
  2. Check which sleep states your PC supports with this command:
    powercfg /a
  3. Find Standby (S0 Low Power Idle) in the output. If it appears, the laptop supports Modern Standby.
  4. Generate the report with this command:
    powercfg /sleepstudy /output "$env:USERPROFILE\sleepstudy.html"
  5. Open sleepstudy.html in a browser.
  6. Look for long sessions on battery with heavy drain.
  7. Open the detailed Top Offenders entries for those sessions.

Top Offenders names the components that were active, such as devices, networking and software, so you know where to look next.

SleepStudy works only on newer laptops that have Modern Standby. Older machines limited to S3 sleep can’t use it as a general sleep diagnostic.

By default the report spans three days. For a longer window, such as seven days, append /duration 7 to the command.

Search the event log for unexpected shutdowns

Sudden reboots can signal serious hardware problems. The first step is to pull recent Kernel-Power events from the System log.

  1. Open PowerShell as administrator.
  2. Run this command, placing each entry inside the braces on a separate line:
    Get-WinEvent -FilterHashtable @{
    LogName='System'
    ProviderName='Microsoft-Windows-Kernel-Power'
    Id=41
    StartTime=(Get-Date).AddDays(-14)
    } | Select-Object TimeCreated, Id, Message | Format-List
  3. Write down when each event happened, then open Event Viewer and review the events logged around that time.

Because the command limits results to the past 14 days, you won’t have to wade through unrelated entries.

Event 41 tells you Windows detected an unclean shutdown. That isn’t automatically a hardware fault: crashes, power outages and forced shutdowns all trigger it. Windows writes the event on the following startup, so the timestamp doesn’t match the exact moment things failed. Use it to pick out the right reboot, then read the events nearby.

A nonzero BugCheckCode in the event details can steer you toward investigating a blue screen. A value of zero doesn’t prove the power supply is at fault. Windows can also log a warning when the system hits a critical temperature, so keep an eye out for one as you go through the logs.

Check and repair Windows system files with DISM and SFC

If Windows itself appears broken, inspect the component store (the files Windows draws on to repair itself) before thinking about a full reinstall.

  1. Open PowerShell as administrator.
  2. Scan for corruption in the component store with this command:
    DISM.exe /Online /Cleanup-Image /ScanHealth
  3. If the scan finds repairable corruption, fix it with this command:
    DISM.exe /Online /Cleanup-Image /RestoreHealth
  4. After DISM completes, check protected system files with this command:
    sfc /scannow
  5. Keep the window open until verification hits 100%.

In the DISM command, /Online points at the Windows installation you’re currently running, and /ScanHealth only looks for corruption without fixing it. SFC works differently and tries to repair problems while it scans.

When SFC finishes, its message reports one of three outcomes: no integrity violations, problems repaired, or corruption it couldn’t repair. DISM usually downloads repair files from Windows Update. Without access to Windows Update, you may need a separate repair source.

Both scans are also useful as regular maintenance. Running them from time to time catches corruption early.

Frequently asked questions

If Get-StorageReliabilityCounter returns blank fields, is my drive OK?

No. Some drives, controllers and connection paths don’t report these values, so empty fields say nothing about the drive’s condition.

Is Kernel-Power Event 41 a sign my power supply is dying?

No. Event 41 means Windows detected an unclean shutdown, and crashes, power interruptions and forced shutdowns can all cause one. A BugCheckCode of zero doesn’t prove a power-supply fault either.

Why won’t the SleepStudy report run on my laptop?

SleepStudy only works on PCs with Modern Standby. Run powercfg /a, and if Standby (S0 Low Power Idle) doesn’t appear, your machine doesn’t support it.

What should I take to a repair shop if I still need one?

Take the saved reports and command output, plus notes on when the symptoms show up. Back up your important files beforehand. A technician gets far more from that than from “my PC has been acting weird.”