I Thought PowerShell Was Just a Better CMD and I Was Wrong

by Admin
I Thought PowerShell Was Just a Better CMD and I Was Wrong

Seeing all these great articles about how powerful Powershell on Windows is, I opened it up to see what the fuss is all about. I saw a command prompt-style window with a familiar-looking prompt and figured I understood it. Just a different command prompt, right? Turns out (and it’s embarrassing to say so) I might as well have called the space shuttle a faster airplane.

PowerShell isn’t an upgrade to Command Prompt (CMD) but a fundamentally different tool built on a different philosophy. Once you understand what that is, then, you’ll see this specific command line shell in a completely different way.

What Is Windows PowerShell?

You know about Command Prompt. But what is Windows PowerShell?

CMD and PowerShell aren’t really the same kind of thing

They just look similar, is all

Windows powershell showing failed sign in attempt
Pankil Shah / MakeUseOf
Credit: Pankil Shah / MakeUseOf

Command Prompt has been part of the Windows experience since the MS-DOS era and it really hasn’t changed much since then. It does what it’s always done, taking a command, running it, and printing resulting text out to the screen. Introduced in 2006, PowerShell looks similar on the surface, which was by design. Commands like dir and cls work in PowerShell, too, but they’re actually aliases, or shortcuts, that map to the actual PowerShell commands underneath. Typing dir in PowerShell actually runs Get-ChildItem behind the scenes. The familiar style is a courtesy for folks migrating from Command Prompt, but may actually confuse folks like me who are new to the whole command line on Windows.

One spits out text, the other hands you usable data

Closeup view of PowerShell file duplicate finding command with result.
Image taken by Yadullah Abidi | No attribution required.

When you run a command in CMD, you’ll get text. When you run a command in PowerShell, you’ll get an object, a structured piece of data with named fields that you can then query. For example, if you ask CMD to list your files, it will give you the list but you can’t do anything programmatically with it, like a metaphorical piece of paper. If you ask PowerShell to list your files, though, it will hand you the metaphorical equivalent of a spreadsheet: each file is a row, with columns for name, size, date modified, and more. They can instantly be filtered or sorted.

That affects a common feature between the two apps: the pipeline, the | character you can use to chain commands together. In the Command Prompt app, piping can only pass text from one command to the next. It’s useful, but not as powerful as in PowerShell, where the pipe command passes the full object. The next command in the chain will get all the fields without having to parse anything.

A command like Get-Process | Where-Object {$_.CPU -gt 1} | Sort-Object CPU translates to “get all running processes, keep only the ones using more than 1% CPU, and then sort them by CPU usage. There are three steps there, all on one line, with no need to parse the text output from each step. This kind of PowerShell scripting can be very powerful.

What that actually makes possible

PowerShell can save you a ton of time

Closeup view of PowerShell with terminal command and result.
Image taken by Yadullah Abidi | No attribution required.

For us everyday Windows users, this practical payoff comes in a couple of areas. First of all, it makes it much easier to automate batch renaming of files, clean out temp folders, monitor disk space, and update all your installed apps in one command via winget, all without clicking through GUI menus. There are plenty of maintenance tasks that take mere seconds to do in PowerShell. You can also query your own system in ways Task Manager doesn’t let you, like finding exactly which process is using up too much RAM, listing everything set to run at startup, or pulling a full inventory of installed software.

If you use Microsoft services at work, too, PowerShell automation can go even further. It integrates directly with Microsoft 365, Azure, Active Directory, Exchange Online, and Teams. These are tasks that CMD just can’t do. Plus, because the scripts are reusable, something you write once for IT admin purposes can work reliably across hundreds of machines.

It’s cross-platform?

PowerShell 7 for macOS webpage

Surprising this Mac user, it turns out that Microsoft open sourced PowerShell and released it in 2016 for macOS and Linux. The version of PowerShell built into Windows 10 and 11 (PowerShell 5.1) is frozen in place, receiving security patches but no new features. PowerShell 7 runs on Windows, Mac, and Linux, is maintained on GitHub, and is built on .NET Core rather than the older .NET Framework.

That lets Mac users in mixed environments manage Azure resources, run the same automation scripts your Windows colleagues use, and script cross-platform workflows without having to rewrite everything on a per-OS basis. Try that with Command Prompt (spoiler, you can’t).

Start learning more

The dir command still works in PowerShell, too. Nothing forces you to change how you use it on the surface. But now that you know what’s underneath, and you want to start exploring, run Get-Help inside PowerShell for a good start learning all the PowerShell essential commands.

Related Posts

Leave a Comment