Lesson 1 • Beginner
Introduction to PowerShell ⚡
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."Hello from PowerShell!
Monday, June 15
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!
# MondayHi, Sam!
Monday___, then run it for free at onecompiler.com/powershell and check it against the expected output.2. 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.Name Id CPU
---- -- ---
chrome 4821 812.45
pwsh 1990 120.30
code 3102 98.17Your 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
# ✅ Expected output (a table of 5 rows):
# Name Id WS
# ---- -- --
# chrome 4821 612048896
# ...Name Id WS
---- -- --
chrome 4821 612048896
code 3102 430112768
pwsh 1990 198344704
explorer 900 142671872
Teams 5567 120033280___ with the cmdlet that selects rows/columns, then run it at onecompiler.com/powershell. (Your numbers will differ — the shape of the table is what matters.)🔎 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-MemberCommandType Name Source
----------- ---- ------
Cmdlet Get-Process Microsoft.PowerShell.Management
Cmdlet Start-Process Microsoft.PowerShell.Management
Cmdlet Stop-Process Microsoft.PowerShell.Management
NAME
Get-Date
-------------------------- Example 1 --------------------------
Get-Date -Format "yyyy-MM-dd"
TypeName: System.DateTime
Name MemberType Definition
---- ---------- ----------
DayOfWeek Property System.DayOfWeek DayOfWeek {get;}
ToString Method string ToString()Common Errors (and the fix)
- "...cannot be loaded because running scripts is disabled on this system" — the execution policy is blocking a
.ps1file. Allow your own scripts withSet-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-processworks. By convention you still writeGet-Processin PascalCase — it's far easier to read and is what every example uses. - Confusing
Write-HostandWrite-Output:Write-Outputsends an object down the pipeline (so the next command can use it);Write-Hostonly paints text on screen. PreferWrite-Outputunless 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 |
Frequently Asked Questions
Q: 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.
Q: 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.
Q: 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.
Q: 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.
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, andGet-Processare your first everyday cmdlets - ✅
Get-Command,Get-Help, andGet-Memberlet PowerShell teach you the rest - ✅ Next lesson: Cmdlets and Syntax — parameters, aliases, and building longer pipelines
Sign up for free to track which lessons you've completed and get learning reminders.