Cheat Sheets

JPNAS.NET / Cheat Sheets

🪟 Windows CMD & PowerShell

Commands for Windows 10 and 11 that save a lot of clicking – files, system information, repairs, installing programs and logs. Most work in both Command Prompt and PowerShell; PowerShell-only commands are the ones with a dash, like Get-Process.

Open in the interactive Cheat Sheets

Files and folders

dir Get-ChildItem -ForceList files / in PowerShell, also hidden ones.
cd "C:\Users\Jernej\Documents"Change folder. Quotes are needed when the path has spaces.
mkdir projectsMake a folder.
copy a.txt b.txt move a.txt D:\Copy / move a file.
robocopy C:\Data D:\Backup\Data /ECopy a folder with all subfolders – fast, and it continues after errors.
robocopy C:\Data D:\Backup\Data /MIRMake the target an exact mirror. Careful: files missing in the source are deleted in the target.
del file.txt Remove-Item folder -RecurseDelete a file / a whole folder.
Get-Content app.log -Tail 20 -WaitShow the end of a log and follow it live.

System information

winverWhich Windows version and build.
systeminfoEverything at once: Windows, BIOS, RAM, install date, updates.
Get-ComputerInfo | Select-Object CsName, OsName, OsVersionThe same in PowerShell, only the fields you want.
tasklist Get-ProcessRunning programs.
taskkill /IM notepad.exe /FForce a program to close by name.
Get-VolumeAll drives with size and free space.
powercfg /batteryreportBattery health report of a laptop (saved as an HTML file).

Repair (run as administrator)

sfc /scannowCheck and repair Windows system files.
DISM /Online /Cleanup-Image /RestoreHealthRepair the Windows image that sfc uses. Run it first if sfc can't fix something.
chkdsk C: /fCheck the file system on C: – runs at the next restart.
shutdown /r /t 0Restart now.
shutdown /r /o /t 0Restart into the recovery options (safe mode, startup repair).

Installing programs (winget)

winget search firefoxFind a program.
winget install --id Mozilla.Firefox -eInstall it by its exact id.
winget upgradeShow which programs have updates.
winget upgrade --allUpdate everything that winget knows.
winget export -o apps.jsonSave the list of installed programs – handy for a new PC (winget import -i apps.json).

Users, policies and security

whoami net userWho is logged in / all local users.
gpupdate /forceApply group policies now, without a restart.
manage-bde -statusIs BitLocker turned on, and for which drives.
Get-FileHash file.iso -Algorithm SHA256Checksum of a download, to compare with the one on the website.
Get-ExecutionPolicy Set-ExecutionPolicy RemoteSigned -Scope CurrentUserCheck / allow running your own PowerShell scripts.

Logs

eventvwr.mscOpen Event Viewer.
Get-WinEvent -LogName System -MaxEvents 30The last 30 system events.
Get-WinEvent -FilterHashtable @{LogName='System'; Level=2} -MaxEvents 20Only the last 20 errors.

Useful shortcuts

Win+XQuick menu: Terminal (Admin), Device Manager, Disk Management …
Win+R → msconfig / services.msc / devmgmt.mscSystem configuration / services / devices.
Ctrl+Shift+EscTask Manager directly.
Win+Shift+SScreenshot of a part of the screen.