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 -Force | List files / in PowerShell, also hidden ones. |
cd "C:\Users\Jernej\Documents" | Change folder. Quotes are needed when the path has spaces. |
mkdir projects | Make a folder. |
copy a.txt b.txt move a.txt D:\ | Copy / move a file. |
robocopy C:\Data D:\Backup\Data /E | Copy a folder with all subfolders – fast, and it continues after errors. |
robocopy C:\Data D:\Backup\Data /MIR | Make the target an exact mirror. Careful: files missing in the source are deleted in the target. |
del file.txt Remove-Item folder -Recurse | Delete a file / a whole folder. |
Get-Content app.log -Tail 20 -Wait | Show the end of a log and follow it live. |
System information
winver | Which Windows version and build. |
systeminfo | Everything at once: Windows, BIOS, RAM, install date, updates. |
Get-ComputerInfo | Select-Object CsName, OsName, OsVersion | The same in PowerShell, only the fields you want. |
tasklist Get-Process | Running programs. |
taskkill /IM notepad.exe /F | Force a program to close by name. |
Get-Volume | All drives with size and free space. |
powercfg /batteryreport | Battery health report of a laptop (saved as an HTML file). |
Repair (run as administrator)
sfc /scannow | Check and repair Windows system files. |
DISM /Online /Cleanup-Image /RestoreHealth | Repair the Windows image that sfc uses. Run it first if sfc can't fix something. |
chkdsk C: /f | Check the file system on C: – runs at the next restart. |
shutdown /r /t 0 | Restart now. |
shutdown /r /o /t 0 | Restart into the recovery options (safe mode, startup repair). |
Installing programs (winget)
winget search firefox | Find a program. |
winget install --id Mozilla.Firefox -e | Install it by its exact id. |
winget upgrade | Show which programs have updates. |
winget upgrade --all | Update everything that winget knows. |
winget export -o apps.json | Save the list of installed programs – handy for a new PC (winget import -i apps.json). |
Users, policies and security
whoami net user | Who is logged in / all local users. |
gpupdate /force | Apply group policies now, without a restart. |
manage-bde -status | Is BitLocker turned on, and for which drives. |
Get-FileHash file.iso -Algorithm SHA256 | Checksum of a download, to compare with the one on the website. |
Get-ExecutionPolicy Set-ExecutionPolicy RemoteSigned -Scope CurrentUser | Check / allow running your own PowerShell scripts. |
Logs
eventvwr.msc | Open Event Viewer. |
Get-WinEvent -LogName System -MaxEvents 30 | The last 30 system events. |
Get-WinEvent -FilterHashtable @{LogName='System'; Level=2} -MaxEvents 20 | Only the last 20 errors. |
Useful shortcuts
Win+X | Quick menu: Terminal (Admin), Device Manager, Disk Management … |
Win+R → msconfig / services.msc / devmgmt.msc | System configuration / services / devices. |
Ctrl+Shift+Esc | Task Manager directly. |
Win+Shift+S | Screenshot of a part of the screen. |