keepcalculator

06 Numbers and Powers

Power Command Line: What It Is & How to Use It

Card No. 06·16121 · Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered
You enter
Finish time, Distance
You get
Average pace, Average speed
Rounding
2 dp

Yes, PowerShell is the command line you’re asking about — it’s Microsoft’s task automation and configuration management framework, and it’s the modern replacement for the old Command Prompt (cmd.exe) on Windows. You use it by typing commands into a blue window to manage files, run programs, and automate repetitive tasks; this article explains what PowerShell is, how it differs from cmd, and how to start using it safely.

What PowerShell Actually Is

PowerShell is a command-line shell and scripting language built on the .NET framework. It was first released in 2006 as “Monad,” then renamed PowerShell 1.0. The key difference from older shells: instead of returning plain text, PowerShell commands (called cmdlets) return structured objects. That means you can pipe the output of one command directly into another and work with properties like file size, process name, or IP address as data, not as text you have to parse.

PowerShell comes in two editions:

  • Windows PowerShell 5.1 — the built-in version on Windows 10 and 11, runs on .NET Framework.
  • PowerShell 7+ (Core) — a cross-platform version (Windows, macOS, Linux) built on .NET Core/.NET 5+. You install it separately, and it’s the version Microsoft continues to develop.

You can open Windows PowerShell by pressing Win + R, typing powershell, and pressing Enter. For the older cmd, type cmd instead. PowerShell 7 is launched as pwsh if you’ve installed it.

Why You’d Use PowerShell Instead of Cmd

Cmd is a relic from the 1980s. It can run batch files and simple commands, but it has no native way to handle objects, no consistent syntax for help, and no scripting constructs like real functions or error handling. PowerShell fixes all of that. Here are the concrete advantages:

  • Consistent verb-noun naming — every cmdlet follows Verb-Noun, e.g., Get-Process, Set-Location, Copy-Item. You can guess a command’s name and often be right.
  • Object piping — Get-Process | Where-Object CPU -gt 100 filters processes by CPU usage without parsing text.
  • Built-in help — Get-Help Get-Process shows syntax, parameters, and examples. In cmd, help is inconsistent and often nonexistent.
  • Scripting — you can write .ps1 scripts with loops, functions, try/catch, and modules. Batch files are far more limited.
  • Remote management — Invoke-Command lets you run commands on other machines over WinRM.

For simple tasks like dir or copy, cmd still works fine. But once you need to filter, format, or automate, PowerShell is the right tool.

Basic Commands You’ll Actually Use

If you’re new, start with these. They map to familiar cmd commands:

  • Get-ChildItem (alias dir or ls) — list files and folders.
  • Set-Location (alias cd) — change directory.
  • Get-Content (alias type or cat) — read a text file.
  • Copy-Item (alias copy) — copy files.
  • Remove-Item (alias del) — delete files.
  • Get-Process — list running processes.
  • Get-Service — list Windows services.

Try this: open PowerShell, type Get-Process | Sort-Object CPU -Descending | Select-Object -First 5. That shows the five processes using the most CPU time. In cmd, you’d need third-party tools or complex tasklist parsing to do that.

How to Run a Script Safely

By default, PowerShell blocks running scripts (.ps1 files) to prevent malware. The execution policy is set to Restricted on most Windows client machines. You can check your policy with Get-ExecutionPolicy. To run a script you wrote yourself, you have two safe options:

  1. Right-click the .ps1 file and choose “Run with PowerShell” — this works even under Restricted policy for scripts you create locally.
  2. Change the policy for the current user only: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. This allows local scripts to run, but downloaded scripts must be signed by a trusted publisher.

Never run Set-ExecutionPolicy Unrestricted — it disables all checks and is a common vector for malicious scripts. Also, be careful with any command you copy from the internet. PowerShell has a feature called script block logging that records what you run, but that doesn’t protect you from a bad command.

Common Mistakes Beginners Make

Three mistakes trip up nearly everyone:

  • Forgetting the dash — cmd uses / for switches (e.g., dir /w), but PowerShell uses - (e.g., Get-ChildItem -Name).
  • Using cmd syntax inside PowerShell — many cmd commands work as aliases, but they behave differently. For example, copy in PowerShell is an alias for Copy-Item, and its parameters are different. Use Get-Alias to see what a command actually maps to.
  • Not quoting paths with spaces — always put quotes around paths: Get-ChildItem "C:\My Folder".

Another subtle issue: PowerShell’s echo writes to the pipeline, not to the console. If you want to display a message, use Write-Output or Write-Host. The difference matters when you pipe output to a file.

PowerShell vs. Cmd vs. Bash

If you’re coming from Linux, you might wonder how PowerShell compares to Bash. Both are shells, but they differ fundamentally:

  • Objects vs. text — Bash pipes plain text; PowerShell pipes objects. This makes PowerShell more powerful for complex data manipulation, but it also means you can’t always use the same text-processing tools like grep or awk directly.
  • Case sensitivity — Bash is case-sensitive; PowerShell is not (by default). Get-Process and get-process are the same.
  • Path separators — Bash uses /, PowerShell uses \ on Windows (but accepts / too).
  • Scripting syntax — Bash uses if [ ... ]; then; PowerShell uses if (...) { ... }. PowerShell’s syntax is closer to C# or Java.

For Windows administration, PowerShell is the clear choice. For Linux server management, Bash is standard. PowerShell 7 runs on Linux, but most Linux admins stick with Bash because that’s what the ecosystem uses.

How to Learn More Without Getting Overwhelmed

You don’t need to memorize hundreds of cmdlets. The help system is your best teacher:

  • Get-Command — lists all available commands. Use Get-Command *process* to find anything with “process” in the name.
  • Get-Help Get-Process -Examples — shows real usage examples.
  • Get-Member — pipe any object to it to see its properties and methods: Get-Process | Get-Member.

Also, learn about modules. Many admin functions come as modules you import with Import-Module. For example, Get-Module -ListAvailable shows what’s installed. Microsoft’s official documentation at learn.microsoft.com is comprehensive and free.

Frequently Asked Questions

Is PowerShell the same as Command Prompt?

No. Command Prompt (cmd.exe) is the older, simpler shell. PowerShell is a more powerful shell and scripting language. Both are included in Windows, but PowerShell is the one Microsoft recommends for new work. You can run cmd commands inside PowerShell, but not the other way around.

How do I open PowerShell as administrator?

Click the Start button, type “PowerShell,” right-click “Windows PowerShell” (or “PowerShell 7”), and select “Run as administrator.” Some commands that change system settings require admin rights. You can also press Win + X and choose “Terminal (Admin)” on Windows 11.

What does “execution policy” mean?

It’s a security feature that controls whether scripts can run. The default is Restricted on Windows client, which blocks all .ps1 scripts. RemoteSigned allows local scripts but requires downloaded scripts to be signed. You can check it with Get-ExecutionPolicy and change it with Set-ExecutionPolicy.

Can I use PowerShell on Mac or Linux?

Yes. PowerShell 7 is cross-platform. You can install it via package managers like Homebrew on macOS or apt on Ubuntu. It’s called pwsh when launched. Most cmdlets work the same, though some Windows-specific ones (like Get-Service) have limited functionality.

Is PowerShell a programming language?

Yes, it’s a full scripting language. It supports variables ($x = 5), loops (foreach, while), functions, classes, error handling (try/catch), and more. You can write complex automation scripts just like you would in Python or Perl, but with built-in access to Windows management interfaces.

How do I stop a running PowerShell command?

Press Ctrl + C to interrupt the current command. If a script is stuck, you can close the window, but that may leave background jobs running. Use Get-Job and Stop-Job to manage background jobs gracefully.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0 | 100000
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →