Windows Command Line cheat sheet
The table below is the translation table: the left column is what you pound into cmd.exe, the right is the idiomatic PowerShell. Both run on Windows 11 (and Server) out of the box — no modules to install for any row.
Three mechanics make the pairs not identical and worth learning: cmd.exe is a text pipeline, PowerShell is an object pipeline; cmd flags use a slash (/all) while PowerShell parameters use a dash (-All); and almost every cmd.exe utility (ipconfig, netstat, w32tm, sfc, rundll32-style tools) runs fine inside PowerShell as an external program — which is why sometimes the PowerShell column keeps the original command.
Task by task: the translation table
| Task | cmd | PowerShell |
|---|---|---|
| IP configuration | ipconfig /all | Get-NetIPConfiguration | Select-Object InterfaceAlias, InterfaceDescription, IPv4Address, IPv4DefaultGateway |
| IPv4 addresses only | ipconfig | Get-NetIPAddress -AddressFamily IPv4 |
| Flush DNS cache | ipconfig /flushdns | Clear-DnsClientCache |
| ARP table | arp -a | Get-NetNeighbor -AddressFamily IPv4 |
| Routing table | route print | Get-NetRoute |
| Add a static route | route add 10.20.0.0 mask 255.255.0.0 192.168.1.254 | New-NetRoute -DestinationPrefix 10.20.0.0/16 -NextHop 192.168.1.254 -InterfaceIndex 12 |
| Process list | tasklist | Get-Process |
| Kill by PID | taskkill /pid 2748 /f | Stop-Process -Id 2748 -Force |
| Kill by name | taskkill /im notepad.exe /f | Stop-Process -Name notepad -Force |
| All TCP connections | netstat -ano | Get-NetTCPConnection |
| Connections on one port | netstat -ano | findstr :3389 | Get-NetTCPConnection -LocalPort 3389 |
| System file repair | sfc /scannow | sfc /scannow (no cmdlet exists — run it from PowerShell) |
| Repair the component store | DISM /Online /Cleanup-Image /RestoreHealth | DISM /Online /Cleanup-Image /RestoreHealth (elevated; no cmdlet exists — run it from PowerShell) |
| Disk / volume status | chkdsk C: | Get-Volume | Select-Object DriveLetter, FileSystemLabel, FileSystem, Size, SizeRemaining |
| Disk free space | dir C:\ | Get-PSDrive -PSProvider FileSystem | Select-Object Name, @{n="UsedGB";e={[math]::Round($_.Used/1GB,1)}}, @{n="FreeGB";e={[math]::Round($_.Free/1GB,1)}} |
| Time service status | w32tm /query /status | Get-Service w32time | Select-Object Status, StartType |
| Immediately resync time | w32tm /resync | w32tm /resync (same utility — elevated; no cmdlet covers resync) |
| Windows edition | winver | Get-ComputerInfo -Property OsName, OsVersion, OsBuildNumber |
| Host name | hostname | $env:COMPUTERNAME |
| Trace a path | tracert example.com | Test-NetConnection -ComputerName example.com -TraceRoute |
| Ping with a fixed count | ping -n 4 example.com | Test-Connection -ComputerName example.com -Count 4 | Select-Object Address, ResponseTime |
| File hash (MD5) | certutil -hashfile C:\temp\disk-usage.log MD5 | Get-FileHash -Path C:\temp\disk-usage.log -Algorithm MD5 | Select-Object Algorithm, Hash |
| Search text in files | findstr /s /i /m error C:\logs\*.log | Get-ChildItem -Path C:\logs -Filter *.log | Select-String -Pattern error |
| Who am I | whoami | [System.Security.Principal.WindowsIdentity]::GetCurrent().Name |
| My token's groups | whoami /groups | whoami /groups (same utility — run it from PowerShell) |
| Output to clipboard | ipconfig | clip | Get-NetIPConfiguration | Out-String | Set-Clipboard |
| Read the clipboard | powershell -Command Get-Clipboard | Get-Clipboard |
| Restart now | shutdown /r /t 0 | Restart-Computer -Force |
| Shut down now | shutdown /s /t 0 | Stop-Computer -Force |
| Event log tail | wevtutil qe System /c:20 /rd:true /f:text | Get-WinEvent -LogName System -MaxEvents 20 |
| DNS lookup | nslookup example.com | Resolve-DnsName example.com |
| System information | systeminfo | Get-ComputerInfo |
dir, copy, del, findstr) are not cmdlets at all. This is why tasklist | SORT works in cmd but something like Get-Process | Where-Object WorkingSet64 only means something in PowerShell — and why PowerShell's natural filters are property comparisons, while cmd's are text grep (... | findstr :3389). Note that wmic is also retired: Microsoft deprecated the WMI command-line utility as of Windows 10 21H1 and does not ship it in some recent builds, another reason the disk-free row above reads dir or PowerShell instead.Translation rules that cover 90% of the pairs
- slash flags vs dash flags
- cmd uses /flag (ipconfig /all); PowerShell uses -Flag. Same utility runs unchanged from PowerShell, but its output stays text there
- text output -> objects
- netstat -ano is text you grep; Get-NetTCPConnection is objects you filter: -LocalPort 3389, -State Listen
- System32 utilities
- ipconfig, netstat, w32tm, sfc and shutdown are external programs — they run from PowerShell unchanged
- cmd help -> PowerShell help
- Get-Help Get-NetTCPConnection -Online opens the reference page; Get-Command -Noun Route lists the cmdlets of a family
Reading the pairs
Notes that keep the table honest
route addin cmd persists only with-p;New-NetRoutepersists by default and takes-InterfaceIndex, which you get fromGet-NetAdapter. Both need an elevated prompt.w32tm /query /statusprints NTP source and last-sync fields; add/verbosefor the full state machine.w32tm /query /configurationshows where the config came from — useful after a GPO edit.Get-NetTCPConnectioncovers TCP only. UDP seesGet-NetUDPEndpoint, andGet-NetTCPConnection -OwningProcess 18948is how a PID's sockets are seen from PowerShell.sfc /scannowis still the file-integrity checker;DISM /Online /Cleanup-Image /RestoreHealthis the component-store repair that should run before it when a corrupted store is the root cause.DISM /Online /Cleanup-Image /RestoreHealthrepairs the component store automatically and takes several minutes; on a machine without Windows Update access point it at known-good files from a mounted image —DISM /Online /Cleanup-Image /RestoreHealth /Source:c:\mount\windows /LimitAccess— the same /Source and /LimitAccess the documentation shows.Stop-ProcessandStop-Computeraccept-WhatIfpreviewed before the first real run — the same lever that makesRestart-Computer -WhatIfthe gentlest way to test a reboot pipeline.
FAQ
Is cmd.exe the same as PowerShell?
No. cmd.exe is a text-mode command interpreter from the DOS lineage: its pipeline passes strings and its built-ins (dir, copy, del, findstr, sort) are internal commands. PowerShell is an object-oriented scripting runtime: every result is a typed .NET object, so filtering means comparing properties instead of grepping text. cmd.exe is still on every Windows box — but it is the middle-aged tool, PowerShell is the one still growing.
Can I run PowerShell commands from cmd.exe?
Yes. cmd.exe accepts PowerShell as an external program: powershell -Command "Get-Process" runs Windows PowerShell 5.1, and pwsh -Command "Get-Process" starts PowerShell 7. For interactive work just launch pwsh.exe or powershell.exe from cmd; for routines, call powershell -ExecutionPolicy Bypass -File your-script.ps1 to skip the ExecutionPolicy inconvenience in a tight loop.
Why do netstat -ano and Get-NetTCPConnection show different results?
Because Get-NetTCPConnection is TCP-only: netstat -ano also lists UDP endpoints (and raw sockets), which do not appear at all in the TCP cmdlet. Use Get-NetUDPEndpoint -LocalPort 123 for the UDP half of the picture. netstat output is also static text sorted as-you-like-it; Get-NetTCPConnection lets you filter by state (-State Listen) or owning process (-OwningProcess 18948) before formatting.
Would the cmd equivalents of del /s /q be better done in PowerShell?
For one-off cleanup, del /s /q does the job. The PowerShell form Remove-Item -Path C:\temp\*, -Recurse -Force is the safer edge of the same work: try it with -WhatIf to preview, and use -Verbose to see each removal. The difference matters at scale, where object filters (Where-Object LastWriteTime -lt (Get-Date).AddDays(-30)) pick files by property rather than name pattern.
Related tools
- IPv4 subnet calculator — break any CIDR block into network, range, broadcast and usable hosts.
- IP range to CIDR — turn an arbitrary address range into its minimal covering CIDR blocks.
- VLSM calculator — split a block into right-sized subnets by host requirements.