Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Windows Server

PowerShell vs cmd: which shell for Windows admin work

PowerShell vs cmd on Windows and Windows Server: objects or text, command equivalents, scripts, remoting, logging and the jobs where cmd is still the tool.

CloudSat teamNovember 18, 20266 min read
Two terminal windows side by side on a deep blue field, one filled with loose lines of text and one with neat rows of stacked blocks
On this pageThree shells on one machine

A fresh Windows Server 2025 machine has two shells before you install anything: the Command Prompt (cmd.exe) and Windows PowerShell 5.1. A third, PowerShell 7, installs alongside them. They overlap, since all three can start ipconfig, robocopy or dism, but they handle output, errors and scripts in very different ways. Knowing which one fits a task saves you from parsing text by hand, and from the few situations where PowerShell is not even available.

Three shells on one machine

cmd Windows PowerShell 5.1 PowerShell 7.6
Program cmd.exe powershell.exe pwsh.exe
Included in Windows Yes Yes No, installs side by side
What the pipeline carries Text .NET objects .NET objects
Script files .bat, .cmd .ps1 .ps1
Platforms Windows Windows Windows, Linux, macOS
Updates With Windows Security fixes only Own releases; 7.6 is LTS until November 2028
Chaining with && Yes No Yes
Encoding of > output Console code page UTF-16 LE UTF-8 without BOM

Windows PowerShell 5.1 is part of the operating system and follows the Windows lifecycle, but it gets no new features. PowerShell 7 is the open-source, cross-platform line under the MIT license. Its current long-term release, 7.6, came out in March 2026 on .NET 10, and the older 7.4 and 7.5 reached end of support on November 10, 2026.

Objects or text: the real difference

In cmd, every command prints text, and the next command has to cut that text apart. In PowerShell, commands pass objects with named properties, so you filter and sort on fields instead of character positions. Finding what listens on which port shows the gap:

netstat -ano | findstr LISTENING
Get-NetTCPConnection -State Listen |
  Sort-Object LocalPort |
  Select-Object LocalAddress, LocalPort, OwningProcess,
    @{n='Process'; e={ (Get-Process -Id $_.OwningProcess).Name }}

The cmd version is shorter, and fine for a glance. The PowerShell version names the process, sorts by port and survives a change of language or column width, because it never reads the screen output. The same objects export cleanly with ConvertTo-Json or Export-Csv, which is where scripts that feed monitoring or reports begin.

Command equivalents

Job cmd PowerShell
Find log files under a folder dir /s /b *.log Get-ChildItem -Recurse -Filter *.log
Follow the end of a file none built in Get-Content app.log -Tail 50 -Wait
Search text findstr /i "error" app.log Select-String -Path app.log -Pattern error
Service state sc.exe query wuauserv Get-Service wuauserv
Restart a service net stop spooler && net start spooler Restart-Service spooler
Stop a process taskkill /im notepad.exe /f Stop-Process -Name notepad -Force
Test a TCP port none built in Test-NetConnection 203.0.113.10 -Port 443
Hash a file certutil -hashfile setup.iso SHA256 Get-FileHash setup.iso -Algorithm SHA256
Last 20 system events wevtutil qe System /c:20 /rd:true /f:text Get-WinEvent -LogName System -MaxEvents 20
Hardware and OS facts systeminfo Get-CimInstance Win32_OperatingSystem

WMIC, the old tool many cmd scripts call for hardware and OS details, is deprecated. Replace each wmic line with Get-CimInstance, which reads the same WMI classes.

Traps when you move from cmd to PowerShell

  • Aliases that look familiar. dir, copy and del exist in PowerShell, but they are aliases for cmdlets with different switches, so dir /s fails while dir -Recurse works.
  • Names that point elsewhere. In Windows PowerShell, sc means Set-Content and curl means Invoke-WebRequest. Type sc.exe and curl.exe to reach the real programs. where filters objects; where.exe finds executables.
  • Exit codes. cmd keeps the last result in %ERRORLEVEL%. PowerShell stores a native program's exit code in $LASTEXITCODE, and $? only says whether the last command succeeded.
  • Special characters. $, the backtick and braces mean something to PowerShell. Put arguments for native tools in single quotes, or add --% before them to stop PowerShell from parsing the rest of the line.
  • Encodings. In Windows PowerShell 5.1, > writes UTF-16 files that some tools read as garbage. Use Out-File -Encoding utf8, or PowerShell 7, whose default is UTF-8.
  • Batch files run in a child process. & .\setenv.bat works, but any set it performs disappears when it exits, so variables it defines never reach your PowerShell session.

Scripts, policies and logs

PowerShell scripts are subject to an execution policy: Windows Server defaults to RemoteSigned, Windows 10 and 11 to Restricted. The policy prevents accidents rather than attacks, so set it deliberately and unblock scripts you downloaded and checked:

Get-ExecutionPolicy -List
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Unblock-File .\Install-Agent.ps1

On the security side, PowerShell is the more visible shell. Script block logging records the code that runs (event 4104 in the Microsoft-Windows-PowerShell/Operational log), transcription can save whole sessions, and Microsoft Defender scans scripts through AMSI before they execute. cmd offers nothing comparable beyond process creation auditing. The old PowerShell 2.0 engine, which bypassed those protections, has been removed from Windows 11 24H2 and Windows Server 2025.

Remote management

cmd has winrs for running a command on another machine over WinRM, and little else. PowerShell makes remoting part of the language:

Invoke-Command -ComputerName srv01, srv02 -ScriptBlock { Get-Service W32Time }
Enter-PSSession -ComputerName srv01
Enter-PSSession -HostName admin@203.0.113.10   # PowerShell 7 over SSH

WinRM listens on TCP 5985 (HTTP) and 5986 (HTTPS). Never leave them open to the internet: allow them only from your own address, or use PowerShell 7's SSH transport with key authentication through the OpenSSH server.

Install PowerShell 7 next to Windows PowerShell

PowerShell 7 does not replace powershell.exe; both stay installed, and modules that only work in 5.1 keep working there. Where winget is available:

winget install --id Microsoft.PowerShell --source winget
pwsh -NoLogo -Command '$PSVersionTable.PSVersion'

Otherwise, the MSI package from the PowerShell releases on GitHub installs the same build. A module that refuses to load in 7 can often run through Import-Module <name> -UseWindowsPowerShell, which proxies it through a 5.1 process. Every CloudSat Windows VPS opens over RDP with cmd and Windows PowerShell 5.1 already present, so PowerShell 7 is the only install the examples above need.

When cmd is still the right tool

  • Recovery. The Windows Recovery Environment opens a Command Prompt, not PowerShell. bcdboot, bootrec, diskpart and offline dism and sfc runs happen there, so keep the cmd syntax for those tools in your notes; the DISM and SFC repair guide covers the offline case.
  • Existing batch files. Login scripts, installers and vendor tools often ship as .cmd. Run them as they are; rewrite only when you need to change them.
  • Tiny jobs. ipconfig /all, ping and tracert behave the same in both shells, and cmd opens instantly.

For everything else, especially anything you will run twice, write PowerShell. Choose PowerShell 7 for new scripts and cross-platform work, and Windows PowerShell 5.1 when a module you depend on has not moved yet.

FAQ

Is cmd being removed from Windows?

cmd still ships with Windows 11 and Windows Server 2025 and runs batch files as it always has. It rarely gets new features, and Microsoft's documentation points to PowerShell for automation.

Why does dir /s fail in PowerShell?

dir is an alias for Get-ChildItem, which uses PowerShell parameters. Use dir -Recurse, or run cmd /c dir /s when you need the classic output.

Can PowerShell run my old batch files?

Yes. Call them with & .\script.bat or cmd /c script.bat. They run in a cmd child process, so their exit code lands in $LASTEXITCODE, while environment changes they make stay behind in that process.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.