Windows commands (PowerShell & CMD)

Useful Windows 10 and 11 commands for PowerShell and Command Prompt: repair system files, reset the network, manage apps with winget, generate a battery report and more.

28 commands

Flush the DNS cache

WindowsPowerShell/CMD

Fixes websites that won’t load after a DNS change.

ipconfig /flushdns

Full network configuration

WindowsPowerShell/CMD

IP addresses, DNS servers, MAC addresses and more for every adapter.

ipconfig /all

Repair system files

WindowsPowerShell/CMDAdmin

Scans protected Windows files and repairs corrupted ones.

sfc /scannow

Repair the Windows image

WindowsPowerShell/CMDAdmin

Fixes the component store that sfc relies on. Run it if sfc can’t repair something, then run sfc again.

DISM /Online /Cleanup-Image /RestoreHealth

Check and fix disk errors

WindowsPowerShell/CMDAdminCareful

Finds and repairs file system errors and bad sectors on drive C.

chkdsk C: /f /r

Runs at the next restart and can take hours on large drives.

Reset the network stack

WindowsPowerShell/CMDAdminCareful

Fixes many "connected but no internet" problems.

netsh winsock reset

Restart afterwards. Some VPN software may need reinstalling.

Show a saved Wi-Fi password

WindowsPowerShell/CMD

The password appears next to "Key Content". Use netsh wlan show profiles to list network names.

netsh wlan show profile name="" key=clear

Battery health report

WindowsPowerShell/CMD

Saves an HTML report with design vs. current capacity and usage history.

powercfg /batteryreport

Find what is using a port

WindowsPowerShell/CMD

The last column is the process ID (PID).

netstat -ano | findstr :

Kill a process by PID

WindowsPowerShell/CMDCareful

Force-closes the process.

taskkill /PID /F

Unsaved work in that program is lost.

Kill a program by name

WindowsPowerShell/CMDCareful

Force-closes every running copy of the program.

taskkill /IM /F

Update all apps

WindowsPowerShell

Updates every app winget knows about. Run winget upgrade first to see the list.

winget upgrade --all

Install an app

WindowsPowerShell

Installs an app by ID. Find IDs with winget search.

winget install

List installed apps

WindowsPowerShell

Every installed app with its version.

winget list

Restart into BIOS/UEFI

WindowsPowerShell/CMDAdminCareful

Reboots straight into firmware settings.

shutdown /r /fw /t 0

Restarts immediately. Save your work first.

Shut down after a delay

WindowsPowerShell/CMD

Schedules a shutdown. Cancel it with shutdown /a.

shutdown /s /t

Verify a download’s checksum

WindowsPowerShell

Compare the hash with the one published by the download site.

Get-FileHash "" -Algorithm SHA256

Show PATH one entry per line

WindowsPowerShell

Makes the PATH environment variable readable.

$env:Path -split ';'

Clear temporary files

WindowsPowerShellCareful

Deletes files in your user temp folder. Files in use are skipped.

Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue

Install WSL (Linux on Windows)

WindowsPowerShellAdmin

Installs the Windows Subsystem for Linux with Ubuntu. Restart when prompted.

wsl --install

Copy a file’s contents to the clipboard

WindowsPowerShell

Puts a text file on the clipboard.

Get-Content | Set-Clipboard

Test if a host and port are reachable

WindowsPowerShell

Shows whether a TCP connection succeeds. Handy for firewall debugging.

Test-NetConnection -Port

How long since the last restart

WindowsPowerShell

Shows uptime in days, hours and minutes.

(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

Get the serial number

WindowsPowerShell

Useful for warranty lookups.

Get-CimInstance Win32_BIOS | Select-Object SerialNumber

Classic right-click menu (Windows 11)

WindowsPowerShellCareful

Brings back the full context menu without "Show more options". Delete that key to undo.

reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve; Stop-Process -Name explorer -Force

Edits the registry and restarts Explorer.

Show hidden files in Explorer

WindowsPowerShellCareful

Turns on hidden files and restarts Explorer.

Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name Hidden -Value 1; Stop-Process -Name explorer -Force

Edit the hosts file

WindowsPowerShell/CMDAdmin

Open from an administrator terminal so you can save changes.

notepad C:\Windows\System32\drivers\etc\hosts

System information

WindowsPowerShell/CMD

OS version, install date, memory, hotfixes and more.

systeminfo

Every command copies as plain, clean text: no curly quotes, no long dashes, no invisible characters.