Skip to content

CMD vs PowerShell Cheat Sheet

Last verified September 2026 — runs in your browser

CMD vs PowerShell

Search code, tasks or categories in English or Spanish. Each entry has a link to save or share it.

Showing 42 of 42 commands

Windows: CMD and PowerShell. Replace <…> parameters before running. Aliases are shown separately and are not copied. These are comparable tasks; output can differ.

List files with details

Files · Pattern / syntax

CMD

dir /a

PowerShell

Get-ChildItem -Force

Includes hidden/system entries (dir /a, Get-ChildItem -Force); not a guarantee that access restrictions are bypassed.

Documentation

Remove file

Files · Pattern / syntax

CMD

del <file>

PowerShell

Remove-Item <file>

Alias (Windows): rm

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Remove directory

Files · Pattern / syntax

CMD

rmdir /s /q <dir>

PowerShell

Remove-Item -Recurse -Force <dir>

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Copy file

Files · Pattern / syntax

CMD

copy <src> <dst>

PowerShell

Copy-Item <src> <dst>

Alias (Windows): cp

Documentation

Create empty file

Files · Pattern / syntax

CMD

type nul > <file>

PowerShell

New-Item -ItemType File -Path "<file>"

CMD truncates an existing file. PowerShell New-Item -ItemType File fails if the file already exists unless -Force is used.

Documentation

Current user

System · Pattern / syntax

CMD

whoami

PowerShell

[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
Documentation

Shutdown PC

System · Pattern / syntax

CMD

shutdown /s /t 0

PowerShell

Stop-Computer

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Restart PC

System · Pattern / syntax

CMD

shutdown /r /t 0

PowerShell

Restart-Computer

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Show open ports

Network · Pattern / syntax

CMD

netstat -an

PowerShell

Get-NetTCPConnection

Get-NetTCPConnection shows TCP only. Use Get-NetUDPEndpoint for UDP; these cmdlets require Windows.

Documentation

Trace route

Network · Pattern / syntax

CMD

tracert <host>

PowerShell

Test-Connection -Traceroute <host>

Test-Connection -Traceroute requires PowerShell 6+; in Windows PowerShell 5.1 use tracert.exe.

Documentation

Kill process by name

Processes · Pattern / syntax

CMD

taskkill /im <name> /f

PowerShell

Stop-Process -Name <name> -Force

CMD expects a name such as notepad.exe; Stop-Process -Name expects notepad, without .exe. Forced termination can lose unsaved work.

Documentation

Kill process by PID

Processes · Pattern / syntax

CMD

taskkill /pid <pid> /f

PowerShell

Stop-Process -Id <pid> -Force

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Start a program

Processes · Pattern / syntax

CMD

start "" "<program>"

PowerShell

Start-Process -FilePath "<program>"

The empty first quoted argument is the CMD window title. Put the executable path in the second argument.

Documentation

Stop service

Processes · Pattern / syntax

CMD

net stop <svc>

PowerShell

Stop-Service <svc>

Changes or interrupts the selected target. Check the target and save work before running; elevated permissions may be required.

Documentation

Show disk space

Disk · Pattern / syntax

CMD

powershell -NoProfile -Command "Get-PSDrive -PSProvider FileSystem"

PowerShell

Get-PSDrive -PSProvider FileSystem

Calls Windows PowerShell from CMD; replaces WMIC, which is deprecated and may be unavailable.

Documentation

Show directory size

Disk · Pattern / syntax

CMD

dir /s "<dir>"

PowerShell

(Get-ChildItem -LiteralPath "<dir>" -File -Recurse -Force | Measure-Object -Property Length -Sum).Sum

PowerShell sums file lengths in bytes, not allocated disk space. Hidden files are included; inaccessible files can produce an incomplete total.

Documentation

Format drive

Disk · Pattern / syntax

CMD

format <drive>: /fs:ntfs

PowerShell

Format-Volume -DriveLetter <drive> -FileSystem NTFS

Formatting destroys data on the selected volume. Use a drive letter without a colon for <drive> (CMD adds the colon). Check the volume first; administrator permissions are required.

Documentation

CMD vs PowerShell Cheatsheet

Compare Windows CMD and PowerShell commands for files, system information, networking, processes and disks. Copy each shell separately. Alias hints are excluded from the clipboard; replace parameters such as <file> and <dir> before running. Similar tasks can produce different output in each shell.

Common pitfalls in CMD and PowerShell

Use the shell indicated above each command. Quote paths containing spaces. CMD start treats its first quoted argument as a window title. PowerShell -Traceroute needs version 6 or later, and networking and volume cmdlets here are Windows-specific. Commands that remove files, stop processes or format volumes require checking the target and may need elevated permissions.

  • 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).

By ·