Skip to content

CMD vs PowerShell Cheat Sheet — Complete Reference (40+ equivalents, 2026)

Last verified May 2026 — runs in your browser
CMD vs PowerShell
List files Files
CMD
dir
PowerShell
Get-ChildItem (ls)
List files with details Files
CMD
dir /a
PowerShell
Get-ChildItem -Force
Change directory Files
CMD
cd <dir>
PowerShell
Set-Location <dir> (cd)
Print current directory Files
CMD
cd
PowerShell
Get-Location (pwd)
Create directory Files
CMD
mkdir <dir>
PowerShell
New-Item -ItemType Directory <dir>
Remove file Files
CMD
del <file>
PowerShell
Remove-Item <file> (rm)
Remove directory Files
CMD
rmdir /s /q <dir>
PowerShell
Remove-Item -Recurse -Force <dir>
Copy file Files
CMD
copy <src> <dst>
PowerShell
Copy-Item <src> <dst> (cp)
Copy directory Files
CMD
xcopy <src> <dst> /s /e
PowerShell
Copy-Item -Recurse <src> <dst>
Move/rename file Files
CMD
move <src> <dst>
PowerShell
Move-Item <src> <dst> (mv)
Show file contents Files
CMD
type <file>
PowerShell
Get-Content <file> (cat)
Create empty file Files
CMD
type nul > <file>
PowerShell
New-Item <file>
Find text in file Files
CMD
findstr "text" <file>
PowerShell
Select-String "text" <file>
Find files by name Files
CMD
dir /s /b *name*
PowerShell
Get-ChildItem -Recurse -Filter *name*
Clear screen System
CMD
cls
PowerShell
Clear-Host (cls)
Show date/time System
CMD
date /t && time /t
PowerShell
Get-Date
System info System
CMD
systeminfo
PowerShell
Get-ComputerInfo
Hostname System
CMD
hostname
PowerShell
$env:COMPUTERNAME
Current user System
CMD
whoami
PowerShell
$env:USERNAME
Environment variables System
CMD
set
PowerShell
Get-ChildItem Env:
Set env variable System
CMD
set VAR=value
PowerShell
$env:VAR = "value"
Command history System
CMD
doskey /history
PowerShell
Get-History
Shutdown PC System
CMD
shutdown /s /t 0
PowerShell
Stop-Computer
Restart PC System
CMD
shutdown /r /t 0
PowerShell
Restart-Computer
Ping host Network
CMD
ping <host>
PowerShell
Test-Connection <host>
Show IP config Network
CMD
ipconfig
PowerShell
Get-NetIPAddress
Show IP (detailed) Network
CMD
ipconfig /all
PowerShell
Get-NetIPConfiguration
Flush DNS Network
CMD
ipconfig /flushdns
PowerShell
Clear-DnsClientCache
DNS lookup Network
CMD
nslookup <host>
PowerShell
Resolve-DnsName <host>
Show open ports Network
CMD
netstat -an
PowerShell
Get-NetTCPConnection
Trace route Network
CMD
tracert <host>
PowerShell
Test-Connection -Traceroute <host>
Download file Network
CMD
curl -O <url>
PowerShell
Invoke-WebRequest <url> -OutFile <file>
List processes Processes
CMD
tasklist
PowerShell
Get-Process
Kill process by name Processes
CMD
taskkill /im <name> /f
PowerShell
Stop-Process -Name <name> -Force
Kill process by PID Processes
CMD
taskkill /pid <pid> /f
PowerShell
Stop-Process -Id <pid> -Force
Start a program Processes
CMD
start <program>
PowerShell
Start-Process <program>
List services Processes
CMD
sc query
PowerShell
Get-Service
Start service Processes
CMD
net start <svc>
PowerShell
Start-Service <svc>
Stop service Processes
CMD
net stop <svc>
PowerShell
Stop-Service <svc>
Show disk space Disk
CMD
wmic logicaldisk get size,freespace,caption
PowerShell
Get-PSDrive -PSProvider FileSystem
Show directory size Disk
CMD
dir /s <dir>
PowerShell
(Get-ChildItem -Recurse | Measure-Object Length -Sum).Sum
Format drive Disk
CMD
format <drive>: /fs:ntfs
PowerShell
Format-Volume -DriveLetter <drive>
Showing 42 of 42 commands

CMD vs PowerShell Cheatsheet

Windows has carried two shells for years: the old Command Prompt, which traces its lineage back to MS-DOS conventions from the early eighties, and PowerShell, introduced in 2006 to bring object-aware piping and a .NET-style scripting model to the platform. Both still ship in modern Windows, and every working sysadmin alternates between them depending on what's installed, what's scripted, and what's pasted from Stack Overflow. The cheatsheet below puts 40+ everyday tasks side by side — files, system info, network, processes, disk — so the right syntax for whichever shell happens to be open is one search away. Most trouble juggling the two shells does not come from forgetting commands. It comes from quirks that look harmless until they bite. `set VAR=value` in CMD silently includes any trailing space in the value, which is why the quoted form `set "VAR=value"` is the safer habit. `for /f` parses with `tokens=` and `delims=`, and getting either wrong skips fields without any error. PowerShell, meanwhile, stops on terminating errors only — a `Remove-Item` on a missing file is non-terminating by default and the script carries on. These are the snippets that get pulled up while debugging exactly that: the matching command on the other shell, the flag that quotes properly, the redirection that actually writes, without trawling through `/?` help text from the first line each time.

Common pitfalls in CMD and PowerShell

A few habits earn their place when scripting across both Windows shells. In CMD, quote whole assignments — `set "PATH=%PATH%;C:\bin"` — because trailing whitespace before the closing `&` or newline becomes part of the value otherwise. Variable expansion is `%var%` at parse time and `!var!` after `setlocal enabledelayedexpansion` inside loops, and mixing the two is the source of most empty-string bugs in `for` blocks. In PowerShell, `$ErrorActionPreference = 'Stop'` flips the default non-terminating model so a single `Remove-Item` failure halts the script instead of being logged and ignored. Piping in PowerShell moves objects, not text, so `Get-Process | Where-Object CPU -gt 100` filters on the property directly — no `findstr` needed. Path separators differ in subtle ways too: CMD accepts forward slashes for some built-ins but not all, while PowerShell normalises them through `Join-Path`. PowerShell's `ExecutionPolicy` blocks unsigned scripts by default on workstations, and the most common quick-fix `Set-ExecutionPolicy -Scope Process Bypass` runs only for the current session, which is the safer trade-off when running a one-off downloaded script. Comments also diverge: CMD uses `REM` or `::`, while PowerShell uses `#` for single-line and `<# ... #>` for blocks — pasting a script from one into the other without changing the comment markers is a familiar paper cut. Knowing both shells is less about preference and more about practical compatibility. Legacy batch files written decades ago still ship inside vendor installers and inside pipelines that nobody is going to rewrite, and PowerShell is where every modern Windows automation story now lives, from Active Directory administration to Azure resource provisioning. Most working sysadmins keep one foot in each, switching by what the situation demands rather than by ideology, and a reference that maps the equivalents directly avoids the small but constant cost of context-switching between two mental models that nominally do the same thing but in completely different ways. The cheatsheet groups everything into Files, System, Network, Processes, and Disk so the equivalent on either shell is one click away.

  • 40+ task equivalents between CMD and PowerShell
  • Side-by-side comparison layout
  • Filter by category (Files, System, Network, Processes, Disk)
  • Full-text search across tasks and commands
  • Copy CMD or PowerShell command independently

Free. No signup. Your inputs stay in your browser. Ads via Google AdSense (consent required).