PowerShell — Hands-On Exercises
Four exercises that show what PowerShell can do that Command Prompt cannot. Structured output, pipelines, file filtering, and self-documentation.
You have used the Command Prompt to control folders and files. PowerShell is the next step up — it does everything cmd does, and then some things that are simply not possible in cmd at all.
The difference in one line: cmd gives you text. PowerShell gives you objects.
When cmd runs tasklist, it prints a wall of text. When PowerShell runs Get-Process, it gives you a structured table that you can sort, filter, and export — exactly the way Excel formulas work on a spreadsheet, but for your entire computer.
Work through these four exercises in order. Each one builds on the last.
How to Open PowerShell
Press Windows key + X and select Windows PowerShell (or Terminal, which opens PowerShell by default on Windows 11).
You will see a blue window with a prompt that starts with PS C:\Users\YourName>.
PS. If it starts with just C:\, you are in Command Prompt — close it and open PowerShell instead.Exercise 1 — See Your Computer Like a Spreadsheet
The cmd version — a wall of text:
Open Command Prompt and type:
You get hundreds of lines of plain text. There is no way to sort it by memory, filter to just Chrome, or export it to Excel without writing a complex script.
The PowerShell version — a sortable table:
In PowerShell, type this exactly and press Enter:
You get a clean table: the 10 processes using the most memory, sorted from largest to smallest, with memory shown in megabytes.
What just happened:
Get-Process— got every running process as structured data (objects, like rows in Excel)Sort-Object WorkingSet -Descending— sorted those rows by memory, largest first (like Excel's sort-by-column)Select-Object -First 10 ...— kept only the top 10 rows and chose which columns to show
This is Excel logic — sort, filter, select columns — applied to your entire computer. The same logic runs on thousands of rows as easily as on ten.
-First 10 to -First 5. Run it again. Only 5 rows now. Change WorkingSet to CPU in the Sort-Object part. Now it sorts by CPU instead. You are steering the output by changing one word. That is how code works.Exercise 2 — Find Every PDF in Your Documents Modified This Week
The scenario: A client calls asking you to find all the PDFs you have worked on in the last 7 days. In Windows Explorer, you could search — but you cannot easily export that list to a spreadsheet, and you definitely cannot send the result directly to another script.
Type this in PowerShell and press Enter:
You get a list of every PDF in your Documents folder modified in the last week, sorted newest first, with the file size in kilobytes.
What the pipe | does:
Each | passes the output of one step into the next — exactly like linking Excel formulas. VLOOKUP( FILTER( SORT( ... ) ) ) is the same idea.
Get-ChildItem ... -Recurse -Filter "*.pdf"— find every PDF, in every subfolderWhere-Object { $_.LastWriteTime -gt ... }— keep only the ones modified in the last 7 days (Where-Object= Excel's FILTER)Select-Object Name, LastWriteTime, KB— pick which columns to show (like choosing columns in a pivot)Sort-Object LastWriteTime -Descending— newest first
AddDays(-7) to AddDays(-30). Now it shows everything from the last 30 days. Change *.pdf to *.xlsx. Now it finds Excel files instead. One word changes the entire scope of the search.Exercise 3 — Count What's in Your Downloads Folder by File Type
The scenario: Your Downloads folder has hundreds of files. How many PDFs vs Excel files vs images? In Windows Explorer, there's no quick answer. In PowerShell, three lines.
You get a table — each row is a file type, sorted from "most files" to "fewest." Something like:
The CA application:
Replace Downloads with any client folder. You immediately know what's there — without opening it, without counting manually, without any chance of missing something buried in a subfolder.
Group-Object Extension is the PowerShell equivalent of a pivot table — "group these rows by the Extension column, give me the count per group."
-Recurse after -File to count files in all subfolders too: Get-ChildItem "$env:USERPROFILE\Downloads" -File -Recurse. On a large client folder this might find hundreds of files you didn't know were there.Exercise 4 — PowerShell Explains Itself
One thing PowerShell can do that cmd absolutely cannot: document its own commands in plain English, with examples.
Type this:
PowerShell prints a list of real examples — what the command does, how to use it with different options, what the output looks like.
Every PowerShell command has this built-in help. You never have to Google a command — the documentation is right there.
This is not a trivial feature. When you are writing an automation script and you want to know how a command works, Get-Help CommandName -Examples gives you real working code to start from. cmd has nothing equivalent — every trick has to be found in a forum post or documentation website.
Get-Help *-Object (the asterisk is a wildcard). PowerShell lists every command that ends in -Object. You will see Sort-Object, Where-Object, Group-Object, Select-Object, ForEach-Object — the five most useful commands in PowerShell, all in one family. Everything you did in Exercises 1–3 was combinations of these five.The Difference in One Comparison
| Task | Command Prompt | PowerShell |
|---|---|---|
| List running processes | tasklist — text dump | `Get-Process |
| Find files of a type | Not built in | Get-ChildItem -Recurse -Filter *.pdf |
| Filter by date | Not built in | Where-Object { $_.LastWriteTime -gt ... } |
| Count files by type | Not built in | Group-Object Extension — instant pivot |
| Export to CSV | Not built in | Add ` |
| Learn a command | command /? — brief flag list | Get-Help command -Examples — real examples |
| Automate Excel | Not supported | Import-Excel, Export-Excel via module |
Neither replaces the other. The 240-folder client structure in the previous exercise runs in cmd. These four exercises run in PowerShell. The rule is simple: use the right tool for the job — Command Prompt for fast file and folder work, PowerShell when you need structured output, filtering, or automation.
Bonus — Export Any Pipeline to a CSV
Add | Export-Csv filename.csv -NoTypeInformation to the end of any pipeline and PowerShell writes the result to a spreadsheet file:
Open your Desktop. recent-pdfs.csv is there. Open it in Excel. You have a spreadsheet of every PDF modified in the last 30 days, with name, date, and size — exported from PowerShell in one command.
This is the bridge between PowerShell and Excel: you can do the filtering and analysis in PowerShell, then hand the result to Excel for review or sharing.
What This Shows
You just used PowerShell to:
- Sort running processes by memory — without any mouse involvement
- Find every PDF modified in the last week — in any folder, any depth
- Count files by type across an entire folder — instant pivot table equivalent
- Read built-in documentation — the tool explaining itself
- Export a result directly to Excel
None of these required typing anything particularly long. They required knowing the right command and the right pipe. You have now seen the machine obey precise instructions — folders, files, reports, all from text. Next, you flip the script: instead of typing the instructions yourself, you describe a whole website in plain English and watch AI build it. That is vibe coding — and finding where it falls short is the whole point of the next exercise.
Before you move on — can you do all of this?
Click each item you're confident about. Bring the unchecked ones to your next session.
I ran Get-Process and sorted the output by memory
I found all PDFs modified in the last 7 days in my Documents folder
I counted files by type in my Downloads folder
I used Get-Help to read the built-in documentation for at least one command
I understand why PowerShell uses pipes (|) the same way Excel chains formulas