Command Prompt is the traditional command-line shell in Windows. It provided a way to directly communicate with an app or the operating system via the CLI, automate operations with batch (
.bat) files and run scripts.
PowerShell, which is currently the default command-line shell, extends on these and provides even more robust automation capability. It’s a scripting language in itself with its own ISE and support for cmd and bash commands as well.
Since they both serve similar purposes, you may be wondering, are they really all that different? Is CMD just a simpler version of PowerShell? Is PowerShell going to replace Command Prompt in the future? We’ve answered these and similar queries in the article below.
What is Command Prompt?
Back in the days of MS-DOS, users had to enter commands entirely through the command-line interface (CLI) to operate computers. With time and innovation, MS-DOS was replaced by GUI-based operating systems. But one part of CLI stuck in the form of command prompt, which was first released in 1987.
Command Prompt, also called CMD, is the command-line interpreter in the Windows NT line of operating systems. It interacts with the user via a CLI, which is implemented through the Win32 console.
CMD accepts the user’s inputs (commands) and translates (interprets) them into a form understandable by the computer (machine language.) CMD commands are preset, and each performs a certain task.
These commands can be used for simple purposes (like checking your ping or IP address) to advanced stuff like creating batch files and scripts for automating system administration tasks (installing software, backing up servers, or logging out users on PCs on a large network, for instance).
Performing tasks via CMD is generally faster and more efficient than GUI, especially those that can be done by running batches of commands. As your commands and scripts are stored in a text file, not only are your commands repeatable, they’re also auditable, which is another great benefit.
Command Prompt can be accessed with the run command
What is PowerShell?
PowerShell is a cross-platform command-line shell, a scripting language, and an automation framework, all in one. Built on the new .NET Core framework, PowerShell has been traditionally used by System Administrators.
These days, it’s increasingly popular among DevOps, Cloud Ops, and Developers thanks to features such as pipeline chaining, tab completion/command prediction, aliases, command-line history, PowerShell drives, PowerShell remoting, and more.
PowerShell is commonly used for automatic system management and administration tasks, cloud management, building, testing, and deploying solutions in CI/CD environments, and so on. It can work with technologies like Azure, SQL, Exchange, AWS, Google Cloud, VMWare, and more.
PowerShell uses unique lightweight commands known as cmdlets (pronounced command-lets). In addition to the native cmdlets, PowerShell also supports CMD and Bash commands in the form of aliases. Oh, and you can also create your own custom cmdlets, modules, and functions.
As the default command-line shell, PowerShell can be accessed from the power user menu (Windows + X). Of course, the run command
powershell works just fine as well.
PowerShell VS CMD – The Main Differences
While PowerShell and CMD may look similar at first glance, they’re completely different from each other, from their commands and language structure to the environment and scripting capabilities. Here are the main differences between PowerShell and Command Prompt.
PowerShell supports the creation of new and custom cmdlets, which can be created from a few lines of code while CMD does not.
PowerShell also supports CMD commands and Bash commands in the form of aliases, whereas the same cannot be said for Command Prompt.
Additionally, PowerShell also has native cmdlets for working with Windows Management Instrumentation (WMI) on both local and remote computers, whereas CMD does not.
CMD has a lot of simple batch commands reminiscent of MS-DOS, such as
dir. These can be difficult to understand/remember if you don’t have much experience with them.
On the other hand, PowerShell cmdlets are much easier to learn and interpret because of how the language is structured. PowerShell cmdlets generally follow a Verb-Noun, or sometimes Verb-ModuleNoun format.
Verb indicates what type of action you’re trying to perform. Commonly used verbs include Get (get the details of something), Set (change the state or settings of something), New (Create a new item) and Remove (Delete an existing item). You can get a full list of all possible verbs with the
Module indicates which module contains the command, while Noun indicates what type of item you are working on.
With a consistent format like this, it’s possible to make an educated guess in a lot of situations, which makes the learning process much easier than with command prompt.
Pipes, Objects, and Variables
A pipeline is used to run multiple commands sequentially, where the output from one command is directly used as the input for the next command. The concept of a pipeline isn’t unique to PowerShell.
What is unique is that in PowerShell, objects are used to retrieve and return data, whereas, in Command Prompt, the inputs and outputs are just plain strings. This makes PowerShell more efficient and capable of processing complex data the same way programming languages do, which CMD is incapable of.
In CMD, you have to pass variables into commands in a strict order as the number of variables is limited. There are no such limitations in PowerShell.
Get-Command are commonly used to figure out the commands and get additional information. The help system in PowerShell is also integrated with online help articles.
Get-Help gives you information about how to use this cmdlet. If you use
get-help ip, you get a list of all functions, cmdlets, and aliases related to IP. If you use
get-help set-netipaddress, it only displays information regarding that specific function.
Get-Command displays an extensive list of all commands installed on the computer. You can modify it with various parameters such as
Get-Command -Type Cmdlet for instance.
In the case of CMD, the help command displays a list of available system commands. Typing
help dir, for instance, gives detailed information on the dir command instead. But this doesn’t work with all the commands, in which case, you can instead use
/? as it serves the same purpose. For example,
ping /? displays information about the ping command.
Environment and Scripts
Command Prompt is very limited in that you can only perform basic DOS commands which do not have access to many system management features.
In CMD, you would need to write a script in a notepad, save it as a batch file and run it separately, whereas this can be invoked directly in PowerShell. On that note, CMD scripts are saved as
.bat files, whereas PowerShell scripts are saved as
CMD doesn’t have an ISE (Integrated Scripting Environment) either, which means it simply cannot match the ability of PowerShell to create complex scripts.
PowerShell has access deep into the Windows System and can interact with system objects at the core level. Furthermore, PowerShell’s ISE allows you to write, run, test, and debug commands, aliases, and scripts.
Some other key features of the PowerShell ISE include multiline editing, selective execution, context-sensitive help, tab completion, syntax coloring, support for right-to-left languages, and appearance customization, among others.
Final Verdict – PowerShell VS CMD
To sum it up, here are the main differences between PowerShell and CMD:
|Powershell uses self-contained programming objects called cmdlets that follow a consistent Verb-Noun format.||CMD commands don’t follow a consistent format.|
|It also supports aliases and the creation of custom cmdlets.||CMD doesn’t support aliases or the creation of new commands.|
|Powershell supports Bash commands, and thus Linux systems.||CMD doesn’t support Linux systems.|
|You can pipe outputs as objects in Powershell.||The output from a command in CMD is a string, and you can’t pipe it to another command.|
|Powershell has an ISE.||CMD has no ISE.|
|Powershell has access to programming libraries.||CMD doesn’t have access to programming libraries.|
For the average user, the reason you use the command line most of the time is likely to check your ping or IP. Command Prompt is a perfectly fine tool for this purpose.
Or perhaps you’re an older user proficient in CMD and unwilling to let go of it just yet. CMD isn’t going away anytime soon, so if it’s getting the job done for you, that’s fine too.
But there’s no denying that PowerShell is superior to CMD in almost every metric. PowerShell is extensible, chainable, and offers way more functionality.
The introduction of PowerShell eliminated the hassle sysadmins used to face: manually combing and navigating Windows directories to locate cmdlets in order to automate administration tasks, especially backups, restore, upgrade, and maintenance-related cron-jobs.
Command Prompt simply cannot match PowerShell’s system administration and automation capabilities. This is obvious to most power users and sysadmins alike, which is why Microsoft will likely try to replace cmd with PowerShell eventually. After all, PowerShell can do most of what CMD can and much more.
Most Useful Commands Comparison
Most users have come across an error or two that required them to use command-line tools to resolve the issue. Using powershell or cmd can seem daunting at first, but we trust the table below will be handy in such cases. In it, we’ve compiled some of the most useful powershell cmdlets and cmd commands, and shortly described their function.
|Command Description||PowerShell cmdlet||CMD command|
|Displays list of items and child items in a specified location||Get-ChildItem||dir|
|Gets the content of an item||Get-Content||type|
|Lists available commands with brief description||Get-Command||help|
|Displays detailed information on the specified command||Get-Help||/?|
|Displays the current working location||Get-Location||cd|
|Changes the current working path to a specified one||Set-Location||cd, chdir|
|Lists all running processes||Get-Process||tasklist|
|Stops a running process||Stop-Process||kill taskkill|
|Copies items to another location||Copy-Item||copy, xcopy|
|Moves items to a new location||Move-Item||move|
|Deletes an item||Remove-Item||del, erase|
|Renames an item||Rename-Item||ren, rename|
|Returns the IP address of the system||Get-NetIPAddress||ipconfig|
|Restarts the local system||Restart-Computer||shutdown/r|
|Clears the screen||Clear-Host||cls|