PowerShell vs CMD: Unlocking the Power of Windows
We settle the PowerShell vs CMD argument, comparing the feature sets of both CLIs and how they stack up against each other
PowerShell and CMD are two common command-line interfaces (CLIs) that IT analysts and engineers will encounter early in their career development. Simply put, Microsoft PowerShell was first brought in to replace CMD, packed with more capabilities and powerful integrations that IT administrators can use to manage devices and support teams remotely.
PowerShell is a tool used for configuration and process automation, using a command-line shell and its own scripts. It can be used on Windows, Linux, and macOS, and can also manage machines in cloud environments such as Microsoft Azure.
In contrast, CMD is a command-line interface that has been on Windows operating systems since some of the earliest versions. First released in 1993 with Windows NT, CMD was the main way for administrators and advanced users to unlock more functionality from their systems until Microsoft released Windows PowerShell in 2006.
PowerShell vs CMD: The key differences
PowerShell and CMD are still used in computing today, though not interchangeably. The capabilities of PowerShell far outweigh those of CMD, with more than 130 general command-line tools. It has been the default since 2017, but has not usurped CMD entirely.
Why did Microsoft shift to PowerShell?
PowerShell is significantly more powerful and rich in capabilities compared to CMD; it’s able to manage hundreds of machines across different platforms whereas CMD is only capable of executing much simpler tasks on a smaller scale.
Jeffrey Snover, the head of the PowerShell project team, designed the tool as the missing link between Microsoft's GUI-based administrative tools and the rich set of application programming interfaces (APIs) that expose the company's .NET framework.
The intention was to produce command-line tool that could cater to developers and administrators alike. In this sense, PowerShell was one of the first forays into what became DevOps, a practice that promotes collaboration between developers and operations teams.
Snover was the author of the original ‘Monad’ (code for PowerShell when it was in development) whitepaper from 2022. He said in a 2017 interview that the project was born out of a desire to bring UNIX tools to Windows, but that core architectural differences proved too steep a stumbling block to achieve that goal.
Is PowerShell better than CMD?
Using PowerShell, administrators can interact with objects in more complex ways, using a range of powerful commands. PowerShell comes with its own type of lightweight command called a ‘commandlet’ (CMDlet), which interface with .NET APIs to fill the role of automation scripts.
While CMD is a capable program, it is its capacity and in many ways a holdover from a far earlier era of Windows. It was not built with complex tasks or the cloud in mind, whereas PowerShell can manage devices on Azure, configure cloud storage, or even create and edit virtual machines (VMs).
One of the only reasons many users will open CMD these days is because it’s recognizable and convenient to access. For simple tasks such as checking one’s static IP address, it’s still a perfectly good tool.
PowerShell is an object-oriented tool, by comparison. Objects are representations of items like files and directories that have their own properties and actions that you can call upon in the CLI. PowerShell understands everything in Windows as an object but also lets you create your own object types.
CMDlets come in a simple verb-noun form and enable you to get things done quickly. For example, typing Get-Member gives you information about an object, like its properties or attributes.
Each CMDlet can become part of a chain known as a ‘pipeline’, which lets you use the output of one cmdlet as the input for another. Depicted using the symbol ‘|’, pipelines are also common to the Linux and UNIX Bash shell and allow for very complex processes to be easily automated.
Say you want to create an object in PowerShell. First, input the command:
$message = Write-Output 'PowerShell is awesome'
You've just used the Write-Output CMDlet to assign some text to what many languages would call a variable. Except in PowerShell, it's not a variable but an object with its own methods and properties. You can list them all by piping the $message object to Get-Member:`$message | Get-Member'.
A great number of CMDlets can be piped together to create long chains of commands, with each output added to by the next CMDlet like a car being built on a factory production line.
Piping aside, this kind of object-oriented programming will be familiar to developers who work with languages like Python. You can even make the object give up certain information about itself using the object's name, a dot, and the property name. For example: $message.Length returns 21
You can create CMDlets yourself in a variety of programming languages, including Microsoft's own C#. An alternative approach to creating your own PowerShell programs is to write scripts, which are collections of PowerShell commands collected together into a file that you can run. Although CMD also allows scripts, PowerShell provides its own interactive scripting environment (PowerShell ISE) with a range of extra features like Intellisense, which gives you context-aware methods and property options as you're typing.
Another thing PowerShell can do that CMD cannot is create modules. These are packages of related scripts and/or CMDlets that call upon each other to help carry out a bigger task. It is far easier to share lots of complementary scripts and CMDlets as a module, and sharing is a big part of the PowerShell story. For example, there's a PowerShell gallery containing thousands of scripts and modules from developers.
PowerShell keeps evolving
In 2016, PowerShell was taken open source as PowerShell Core, and since then it has been ported over to Linux and macOS as an alternative to the common Bash shell. However, if you’re planning on installing PowerShell on something other than Windows, you’re also going to have to lift .NET Core (the open source equivalent to Windows .NET) onto the system too. It’s also important to keep in mind that some functionality won’t transfer over - for example, it won’t support the ISE scripting environment.
PowerShell has been updated and expanded upon over the years since, with new functionality and support for classes (objects that can be used as templates to create other objects), as well as integrations with things like Visual Studio Code - which is available for both the native Windows and open source versions.
So now you know its history and how it works, the question remains: Should you use it?
While it may seem to have a steep learning curve at first, PowerShell becomes far easier to use with practice. Once you get to grips with its basics, you’ll find PowerShell an effective program with plenty of useful features. It’s unlikely that you’ll use all the different features that PowerShell has, but even if used in a limited capacity it can be a lifesaver - the IT equivalent of a well-stocked toolbox.
Get the ITPro. daily newsletter
Receive our latest news, industry updates, featured resources and more. Sign up today to receive our FREE report on AI cyber crime & security - newly updated for 2024.
Danny Bradbury has been a print journalist specialising in technology since 1989 and a freelance writer since 1994. He has written for national publications on both sides of the Atlantic and has won awards for his investigative cybersecurity journalism work and his arts and culture writing.
Danny writes about many different technology issues for audiences ranging from consumers through to software developers and CIOs. He also ghostwrites articles for many C-suite business executives in the technology sector and has worked as a presenter for multiple webinars and podcasts.