Introduction to PowerShell
Reviewed & published by Brayan K
PowerShell is Microsoft's object-oriented, cross-platform shell and scripting language that pipes structured .NET objects, rather than plain text, between its Verb-Noun commands called cmdlets.
Part of the free PowerShell course at LearnCodingFast — hands-on lessons with worked examples and the output they print, plus practice exercises and a quick quiz.
By the end of this lesson you'll understand what makes PowerShell special — it pipes objects, not text — read and write your first Verb-Noun cmdlets, and use Get-Help and Get-Command to teach yourself any command you'll ever need.
What You'll Learn
- What PowerShell is: an object-oriented, cross-platform shell
- Why the pipeline passes objects, not plain text like bash
- The Verb-Noun naming convention that makes cmdlets predictable
- Run your first cmdlets: Write-Output, Get-Date, Get-Process
- Discover any command with Get-Command and Get-Help
- Avoid the execution-policy trap that blocks beginners' scripts
Real-World Analogy
Think of an old shell like bash as handing you a printed newspaper: you get a wall of text, and to find one fact you scan and cut out the right words by hand. PowerShell hands you a spreadsheet instead — rows, columns, and labelled cells. To get the busiest process you don't slice text; you simply say "sort by the CPU column and give me the top 3". Because PowerShell moves real objects (data with named properties) between commands rather than raw text, you ask for things by name — and your commands stop breaking the moment a layout changes.
1. What PowerShell Is (and Your First Cmdlets)
PowerShell is Microsoft's object-oriented, cross-platform shell and scripting language. A shell is a program that runs commands you type; "object-oriented" means each command hands back structured data (built on .NET) rather than plain text. The commands are called cmdlets (pronounced "command-lets"), and you'll meet three of the most common ones below: Write-Output prints a value, Get-Date returns the current date/time, and (later) Get-Process lists running programs. Read this worked example, run it, and confirm your output matches.
# Your very first PowerShell commands.
# A "cmdlet" (command-let) is a built-in command. Each prints its result.
# Write-Output sends a value down the pipeline (here, a line of text).
Write-Output "Hello from PowerShell!"
# Get-Date returns a real date/time OBJECT, not just text.
# -Format turns that object into a string the way you want it.
Get-Date -Format "dddd, MMMM dd"
# Cmdlets are always named Verb-Noun. "Get" fetches; "Process" is the thing.
Write-Output "Done."Now you try. The script below is almost complete — fill in the two blanks marked ___ using the hints in the # comments, then run it.
# 🎯 YOUR TURN — replace each ___ then run the script.
# 1) Print a greeting. Write-Output takes text in "double quotes".
Write-Output ___ # 👉 put your name in quotes, e.g. "Hi, Sam!"
# 2) Print today's weekday name using Get-Date with a format.
# The format "dddd" means the full day name (Monday, Tuesday...).
Get-Date -Format ___ # 👉 replace ___ with "dddd"
# ✅ Expected output (example):
# Hi, Sam!
# Monday2. The Big Idea: Objects, Not Text
This is what sets PowerShell apart from bash, CMD, or zsh. In those shells, a command's output is just text, so to use part of it you slice the text by counting spaces with tools like cut or awk — and it breaks the instant a column shifts. PowerShell sends objects down the pipeline (the | symbol, read as "pipe into"). An object carries named properties — a process object has Name, Id, and CPU — so you ask for data by name. Compare the two approaches in the comments below.
# THE BIG IDEA: PowerShell pipes OBJECTS, not text.
# Get-Process returns process objects. Each one has named properties
# like Name, Id and CPU — so you can sort and pick columns by name.
# 1) Sort processes by the CPU property, biggest first.
# 2) Keep only the top 3.
# 3) Show just the Name, Id and CPU columns as a table.
Get-Process |
Sort-Object CPU -Descending |
Select-Object -First 3 Name, Id, CPU |
Format-Table -AutoSize
# In bash you'd parse this text with cut/awk by counting spaces.
# Here you ask for the "CPU" column by NAME — no text-slicing needed.Your turn again. Memory usage lives in a property called WS (working set). Finish the pipeline by adding the cmdlet that picks which rows and columns to keep.
# 🎯 YOUR TURN — finish the object pipeline.
# Goal: show the 5 processes using the most memory (the WS property).
# Get-Process gives you objects. Pipe (|) them into the next command.
Get-Process |
Sort-Object WS -Descending |
___ -First 5 Name, Id, WS # 👉 the cmdlet that PICKS columns/rows
# What you should see: a five-row table with Name, Id and WS columns, the
# largest WS first. The actual names and numbers are your machine's running
# processes, so no two people get the same answer — check the shape.🔎 bash vs PowerShell, side by side
| Goal | bash (text) | PowerShell (objects) |
|---|---|---|
| Busiest process | ps aux | sort -rk3 | head | Get-Process | Sort-Object CPU -Descending |
| Pick one column | ... | awk '{print $1}' | ... | Select-Object Name |
| Count items | ... | wc -l | (Get-Process).Count |
The bash column relies on the output's exact spacing; the PowerShell column names the data directly, so it keeps working when the display changes.
3. Verb-Noun Naming & Teaching Yourself
Every cmdlet is named Verb-Noun: an approved verb plus a singular noun. Get-Process reads processes; Stop-Process ends one; Get-Date reads the date. Learn the common verbs — Get, Set, New, Remove — and you can often guess a command before looking it up. When you can't guess, three cmdlets let PowerShell teach you: Get-Command finds cmdlets by pattern, Get-Help explains one (add -Examples for copy-paste usage), and Get-Member reveals an object's properties so you know what you can sort or select by.
# When you don't know a cmdlet, ASK PowerShell itself.
# Get-Command finds cmdlets. *Process* matches anything with "Process".
Get-Command *Process*
# Get-Help explains a cmdlet. -Examples shows ready-to-copy usage.
Get-Help Get-Date -Examples
# Get-Member lists the properties & methods on whatever an object has.
# (This is how you discover that Get-Date objects have a .DayOfWeek.)
Get-Date | Get-MemberCommon Errors (and the fix)
- "...cannot be loaded because running scripts is disabled on this system" — the execution policy is blocking a .ps1 file. Allow your own scripts with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned. (Typing commands straight into the prompt is never blocked.)
- "The term 'Get-Proces' is not recognized as a name of a cmdlet..." — a typo or a cmdlet that isn't installed. Check the spelling and the Verb-Noun shape, or run Get-Command *Process* to find the real name. Press Tab to autocomplete.
- Casing looks "wrong" but still runs: PowerShell is case-insensitive, so get-process works. By convention you still write Get-Process in PascalCase — it's far easier to read and is what every example uses.
- Confusing Write-Host and Write-Output: Write-Output sends an object down the pipeline (so the next command can use it); Write-Host only paints text on screen. Prefer Write-Output unless you specifically want screen-only text.
📋 Quick Reference
| Cmdlet | Alias | What it does |
|---|---|---|
| Write-Output | echo | Send a value down the pipeline |
| Get-Date | — | Current date/time object |
| Get-Process | ps / gps | List running processes |
| Get-Command | gcm | Find cmdlets by pattern |
| Get-Help | help | Show a cmdlet's documentation |
| Sort-Object | sort | Sort objects by a property |
| Select-Object | select | Pick properties / first N rows |
Mini-Challenge: Top CPU Report
No blanks this time — just a brief and an outline. Build the pipeline yourself from the cmdlets you met in this lesson, run it, and compare the shape of your table to the expected result in the comments.
# 🎯 MINI-CHALLENGE: "Top CPU report"
# Using ONLY cmdlets from this lesson, build a one-line pipeline that:
# 1. Gets all running processes (Get-Process)
# 2. Sorts them by the CPU property, highest first
# 3. Keeps just the top 5
# 4. Shows the Name, Id and CPU columns as a tidy table
#
# Hints (cmdlets you've met): Get-Process, Sort-Object,
# Select-Object, Format-Table
#
# ✅ Expected: a 5-row table with columns Name, Id, CPU.
# your pipeline here🎉 Lesson Complete!
- ✅ PowerShell is an object-oriented, cross-platform shell (Windows, macOS, Linux)
- ✅ The pipeline (|) passes objects with named properties — not plain text like bash
- ✅ Cmdlets are named Verb-Noun (Get-Process, Stop-Process) so they're predictable
- ✅ Write-Output, Get-Date, and Get-Process are your first everyday cmdlets
- ✅ Get-Command, Get-Help, and Get-Member let PowerShell teach you the rest
Practice quiz
What does PowerShell pass between commands in its pipeline?
- Plain text lines
- Structured objects
- Raw bytes
- HTML fragments
Answer: Structured objects. Unlike bash, PowerShell pipes structured .NET objects with named properties.
Which naming convention do all cmdlets follow?
- Noun-Verb
- Verb only
- Noun.Verb
- Verb-Noun
Answer: Verb-Noun. Every cmdlet is named Verb-Noun, like Get-Process or Stop-Service.
Which cmdlet returns the current date and time?
- Get-Date
- Show-Time
- Read-Clock
- Get-Now
Answer: Get-Date. Get-Date returns a DateTime object representing the current date and time.
What symbol is the pipeline operator?
- &
- >
- |
- %
Answer: |. The | symbol pipes one cmdlet's output into the next cmdlet.
Which cmdlet sends a value down the pipeline?
- Print-Line
- Echo-Text
- Write-Output
- Say-Value
Answer: Write-Output. Write-Output sends an object down the pipeline so the next command can use it.
Which cmdlet finds other cmdlets by pattern?
- Get-Command
- Find-Cmdlet
- Search-Help
- List-Commands
Answer: Get-Command. Get-Command finds cmdlets, e.g. Get-Command *Process*.
Which cmdlet lists an object's properties and methods?
- Get-Property
- Show-Object
- Get-Detail
- Get-Member
Answer: Get-Member. Get-Member reveals the properties and methods available on an object.
How do you sort process objects by their CPU property, highest first?
- Order-By CPU
- Arrange CPU -Down
- Sort-Object CPU -Descending
- Get-Process -SortCPU
Answer: Sort-Object CPU -Descending. Sort-Object CPU -Descending sorts objects by the named CPU property, largest first.
Is PowerShell case-sensitive when typing cmdlet names?
- Yes, always
- No, it is case-insensitive
- Only for nouns
- Only for verbs
Answer: No, it is case-insensitive. PowerShell is case-insensitive, so get-process and Get-Process both work.
What does Set-ExecutionPolicy RemoteSigned help with?
- Speeding up cmdlets
- Renaming cmdlets
- Hiding the prompt
- Allowing your own scripts to run
Answer: Allowing your own scripts to run. It lets your own local .ps1 scripts run while still requiring downloaded ones to be signed.
Continue this course
- Next: Cmdlets and Syntax — The Verb-Noun naming convention, parameters, and common built-in cmdlets
Frequently asked questions
Is PowerShell only for Windows?
No. Windows PowerShell 5.1 ships with Windows, but the modern PowerShell 7+ (the 'pwsh' command) is cross-platform and runs on Windows, macOS and Linux. The cmdlets and the object pipeline work the same way on all of them.
What is the difference between PowerShell and bash?
Bash passes plain text between commands, so you slice that text with tools like grep, cut and awk. PowerShell passes structured .NET objects, so instead of parsing text you ask for a property by name (for example Sort-Object CPU). That makes PowerShell more reliable for automation because there is no fragile text-parsing step.
Why are commands named with a dash, like Get-Process?
Every cmdlet follows a Verb-Noun convention: an approved verb (Get, Set, New, Remove) plus a singular noun. Once you learn the verbs, you can guess command names — if Get-Process reads processes, Stop-Process ends one. It makes thousands of cmdlets predictable.
I get an error that scripts are disabled — how do I fix it?
Windows blocks .ps1 scripts by default for safety. Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned to allow your own scripts to run while still requiring downloaded ones to be signed. Typing commands directly into the prompt is never blocked by this policy.