Back in the day, booting the then-cutting-edge IBM 8086 from the floppy brought you to a green text screen with a cursor blinking at the familiar C:\> prompt. Hacking boot.ini and config.sys to get my games to run was my first introduction to programming.
Eventually that C:\> got replaced with a pretty GUI and boot from hard disk. That command prompt (CMD) still lived on for decades. Only recently did CMD get an upgrade, or replacement, with PowerShell, the shell application Microsoft introduced with Windows 7.
CMD served us well for a good long time, but PowerShell is like going straight from steam engines to autonomous battery powered cars.
Windows Command Prompt
Windows Command Prompt – also known as CMD – is the original shell for the Microsoft DOS operating system. CMD was the default shell until Windows 10 build 14791 when Microsoft made PowerShell the default option. CMD is one of the last remnants of the original MS-DOS operating system that Microsoft replaced.
But before you jump into it, there’s one significant difference that you need to understand, and that’s the difference between Command Prompt and PowerShell. They look pretty similar on the surface, but in practice are vastly unlike each other.
Here’s what you need to know about the two.
The Command Prompt Came First
Starting with Windows NT and beyond, Windows came equipped with a command line interpreter called cmd.exe, better known as Command Prompt. With it, users could interact with the operating system using text-based commands and parameters.
But while Command Prompt came first, it wasn’t the first. Previous versions of the operating system (Windows 95, 98, and ME) had a more primitive command line interpreter called COMMAND.COM, better known as MS-DOS.
It goes without saying that Command Prompt was a huge improvement over the outdated MS-DOS interpreter.
Despite the graphical nature of Windows, the command line has never been — and will never be — obsolete. It offers a degree of power and flexibility that just can’t be achieved with point-and-click interfaces (such as batch scripting), and depending on your proficiency, you can get things done faster using Command Prompt.
Windows PowerShell is the new Microsoft shell that combines the old CMD functionality with a new scripting/cmdlet instruction set with built-in system administration functionality. PowerShell cmdlets allow users and administrators to automate complicated tasks with reusable scripts. System administrators save significant time by automating administration tasks with PowerShell.
PowerShell vs. CMD
PowerShell vs. CMD is like comparing apples to kumquats. They are completely different, despite the illusion that the ‘dir’ command works the same way in both interfaces.
PowerShell uses cmdlets, which are self-contained programming objects that expose the underlying administration options inside of Windows. Before PowerShell, sysadmins navigated the GUI to find these options, and there was no way to reuse the workflow of clicking through the menus to change options on a large scale.
PowerShell uses pipes to chain together cmdlets and share input/output data the same way as other shells, like bash in linux. Pipes allow users to create complex scripts that pass parameters and data from one cmdlet to another. Users can create reusable scripts to automate or make mass changes with variable data – a list of servers, for example.
One of the (many) neat functions of PowerShell is the ability to create aliases for different cmdlets. Aliases allow a user to configure their own names for different cmdlets or scripts, which makes it more straightforward for a user to switch back and forth between different shells: ‘ls’ is a linux bash command that displays directory objects, like the ‘dir’ command. In PowerShell, both ‘ls’ and ‘dir’ are an alias for the cmdlet ‘Get-ChildItem.’
When to Use PowerShell
For systems administrators and other IT functions, PowerShell is the way to go. There isn’t any command left in CMD that isn’t in PowerShell, and PowerShell includes cmdlets for any administration function you could need. Third-party software vendors are extending PowerShell with custom cmdlets, like the NetApp PowerShell Toolkit that manages Data ONTAP.
PowerShell knowledge can be a differentiator for employment or even a job requirement, so it’s a worthwhile skill to invest in.
To get started on your PowerShell journey, check out this tutorial for the basics– and learn how to automate Active Directory tasks with our free PowerShell course by Adam Bertram, a Microsoft PowerShell MVP (pro-tip: use the code ‘blog’).
Credit : varonis.com/blog/powershell-vs-cmd/ makeuseof.com/tag/command-prompt-vs-windows-powershell-whats-difference/