PowerShell has been out for years now, and in that point it has virtually totally eclipsed the outdated cmd.exe shell and develop into more and more highly effective. It is tightly built-in with many core features of the Home windows OS, and may help you script virtually any perform in Home windows. PowerShell hasn’t all the time been the most well-liked language (although many Home windows admins swear by it), however lately it has been on a rampaging comeback, aided by a common push to enhance developer tooling on Home windows with the likes of the brand new Windows Terminal and WSL.
However when you’re new to Home windows, the distinction between PowerShell and the Command Line is perhaps a bit opaque. Basically, they’re totally different instruments, constructed for various functions and for various generations. They’re virtually totally totally different in how they function, and the way they’re designed for use, with PowerShell now by far the extra highly effective of the 2.
With that in thoughts, let’s run by means of among the key variations between PowerShell and CMD, and issues to concentrate on when utilizing them.
3 Language syntax and performance
PowerShell is not only a prettier model of CMD
That is the large, apparent one. PowerShell and cmd.exe function utilizing a very totally different syntax. The command immediate historically interprets batch (.bat or .cmd) scripts and a few fundamental system instructions. These have been usually clunky and troublesome to jot down extra superior scripts for. The form of extensible, interoperable, and dynamic PowerShell scripts we now take pleasure in can be troublesome at greatest to construct in batch. This can be a legacy subject – batch scripting has been round in some type since MS-DOS.
In distinction, PowerShell’s syntax is constructed on high of .NET, which, regardless of not being essentially the most ‘in vogue’ framework on the market, is extraordinarily highly effective inside a Home windows surroundings. It is designed from the bottom up for automation inside Home windows, and has intensive APIs and hooks into the OS. The advantage of that is that the underlying framework is separate from the interface, permitting PowerShell builders to function on a contained API with safeguards in place, as a substitute of attempting to take care of the unwieldy WinAPI instantly.
One other key distinction between the 2 instruments is how they work together with different software program. CMD outputs textual content (which is not essentially a nasty factor, Bash additionally outputs plain textual content), whereas PowerShell outputs .NET Objects. This has some up and down sides, as interoperability inside instruments constructed for PowerShell is less complicated, and instruments can extra simply soak up output from different instruments without having to parse textual content (or deal with verbosity in issues like JSON). This aids automation, and is a gateway into extra complicated system administration on Home windows (although you may usually see PowerShell instruments stray fairly removed from the KISS philosophy of numerous good Unix instruments). Nevertheless, it may make viewing some output tougher, and the formatting could be a bit odd.
2 Cross-platform help
PowerShell on Linux would not have appeared like a joke a decade in the past
Whereas it is not a massively widespread possibility, an enormous distinction between PowerShell and the command immediate is that PowerShell is interoperable with macOS and Linux. The underlying framework for PowerShell (.NET Core) is cross-platform by default, making it far simpler for PowerShell to be developed with cross-platform help in thoughts. This wasn’t all the time the case – cross platform help was solely added with PowerShell Core 6, however fashionable variations of PowerShell ought to work comparatively seamlessly throughout environments.
CMD was solely ever initially developed with Home windows help in thoughts, and lots of of its options are deeply tied to Home windows particular elements inside the working system. The progress of PowerShell right here displays a wider architectural change between CMD and PowerShell, the place PowerShell is essentially constructed on high of .NET Core beneath, whereas CMD usually depends instantly on WinAPI.
The story behind how the PowerShell workforce each open-sourced PowerShell and introduced cross-platform help to it’s an attention-grabbing story of refactoring an older code base, and has been written about in a blog post from 2016.
Associated
The ultimate guide to PowerShell in Windows 11
Need to automate duties in your laptop to be extra productive? PowerShell may help and do many different issues apart from that.
1 PowerShell is open-source (partly)
CMD represents a instrument of the previous for Microsoft, as a closed supply, proprietary instrument which they’ve managed the event of for years. PowerShell, nonetheless, is a part of a departure over the past decade from the Microsoft of the previous. There’s an rising deal with constructing open-source, broadly supported platforms to help the group as a complete, as a substitute of constructing a walled backyard for Home windows. This has concerned every part from VS Code to F#, TypeScript, and the Windows Subsystem for Linux.
PowerShell is not any exception right here, and its growth of PowerShell Core is brazenly tracked on GitHub (additionally now owned by Microsoft, taking this effort a step additional). This permits the group not solely to contribute to and assist steer the event of PowerShell, but additionally makes it a much more reliable instrument to construct on high of. Earlier variations will all the time stay accessible, as will help from the group. That is in distinction to CMD, which by no means felt like a platform designed with fashionable builders in thoughts (and to be truthful, it wasn’t).
The advantages of PowerShell shifting to an open-source license like this embody higher group help, group enter on growth path, a standard platform for bug studies and dialogue, to not point out the power of the group to simply contribute. This mannequin has been very profitable for Microsoft over the past decade, and I hope to see them proceed prioritizing open, community-oriented growth, particularly for instruments constructed for builders or energy customers. Even the likes of PowerToys is open-source!
Associated
The ultimate guide to PowerShell in Windows 11
Need to automate duties in your laptop to be extra productive? PowerShell may help and do many different issues apart from that.
PowerShell is a big enchancment over CMD, and getting higher on a regular basis
CMD was a instrument of its period, and is now clearly outdated on Home windows (and has been for years). Microsoft has been making big strides to enhance this, each with the introduction of the WSL which is a good addition for builders, and the ever bettering capabilities of PowerShell, which is extra oriented in direction of system directors and automators.
PowerShell is getting higher on a regular basis, and Microsoft appears to actually care about its growth. You actually should not be utilizing CMD in 2024 when you can keep away from it, and studying PowerShell is a good way to begin feeling somewhat extra highly effective while you sit down at a Home windows PC.