PowerShell
Step 1. First Steps in PowerShell — Driving Your Computer with Text
Level 0 — Understanding How to Operate a Computer and How It’s Structured | Difficulty ★☆☆☆☆ | Estimated time: 2–3 hours
Prerequisites: none. All you need is one Windows computer. This is the true first page of this book.
- What you need: a Windows PC, a keyboard, and a decision not to be intimidated.
- Safety: This section’s commands list folders and change your working location; they do not create or delete files. Use a normal, non-administrator session. If an error appears, understand it before continuing.
- Screen differences: output may differ slightly from this book depending on Windows 10/11, your PowerShell version, and language settings. As long as the essentials match, you’re fine.
- Attitude: it’s okay not to understand everything — but type every command yourself. Just reading will never make it stick. And an error caused by a typo isn’t failure; it’s tuition. Red text on the screen doesn’t break your computer.
Right now, this is how you use a computer: you double-click folder icons, drag files, and click buttons. That’s called a GUI (graphical user interface). But in the world this book teaches — server administration, hacking, security analysis — both GUIs and CLIs are useful. A CLI is especially useful for remote servers without a desktop and for repeatable tasks. Perform security exercises only in environments you own or are explicitly authorized to test. So starting today, we learn the CLI (command-line interface) — a way of driving the computer with text. Our first tool is PowerShell, already installed on Windows.
Level 0 Roadmap — 6 Units, 40 Steps
Level 0 (Steps 1–40) consists of six units. Reading in order is recommended, but feel free to skip units you already know. The first chapter of each unit carries a unit guide.
| Unit | Steps | What it covers |
|---|---|---|
| Windows & PowerShell | 1–10 | Commands, files, pipes, text processing, first scripts |
| Inside Windows | 11–15 | Registry, event logs, processes, remote management |
| Virtualization & Moving into Linux | 16–22 | Building a VM, installing Ubuntu, basic commands, editors |
| Taming Linux | 23–30 | Permissions, users, processes, bash, cron, SSH |
| How Networks Work | 31–39 | IP, MAC, DNS, ports, TCP/UDP, routing, OSI |
| Comprehensive Test | 40 | A full Level 0 check |
1. Learning Objectives
By the end of this unit, you can:
- Open PowerShell and read your current location from the prompt
- Use
Get-LocationandGet-ChildItemto answer “where am I, and what’s here” - Move around with
cdusing both relative paths and absolute paths - Handle paths containing spaces correctly with quotes
- Cut down on typing with Tab completion and the ↑ key
This section’s goal in one sentence: without opening File Explorer (the GUI), you can move around inside your computer using only commands and figure out “where am I, and what’s here.”
2. Background Knowledge — Today’s Tools and Concepts
This section’s Tools at a Glance
| Category | Details |
|---|---|
| Language/environment | Windows PowerShell 5.1 is sufficient for this lesson. PowerShell 7 also works if already installed. No administrator privileges or additional installation are needed. |
| This section’s commands | Get-Location (=pwd), Get-ChildItem (=ls, dir), cd path |
| This section’s techniques | Tab completion, recalling previous commands with ↑ |
| Concepts you need | CLI vs GUI, terminal and shell, the prompt, the directory tree, absolute vs relative paths, quoting rules |
2-1. Terminals, Shells, and PowerShell
Let’s sort out the terminology first (it’s easy to mix up):
- Terminal: the “window” you type commands into (the dark screen itself)
- Shell: the program inside it that interprets and executes your commands (the translator)
- PowerShell: the name of the shell Microsoft built
A restaurant analogy: the terminal is the “order slip,” and the shell is the “kitchen.” You write text on the slip (enter a command), and the kitchen reads it and sends out the dish (prints the result). What we’re opening today is “a terminal window with a kitchen called PowerShell attached.”
2-2. The Directory Tree — A Map of Your Computer
Files inside a computer are stored in a structure of folders inside folders inside folders. Picture it as an upside-down tree:
C:\ ← the root of drive C
├── Users ← where users live
│ └── Lee ← my home (differs by username)
│ ├── Documents ← documents
│ ├── Downloads ← downloads
│ └── Desktop ← desktop
├── Windows ← the operating system itself
└── Program Files ← installed programs
This is an example tree. Lee is a fictional username; $HOME gives your actual home path. Documents and Desktop may be in OneDrive or on another drive. C:\ is the root of drive C; C: without the backslash is not the same address.
Changing location changes the folder commands work from. It does not move the files themselves.
2-3. Absolute and Relative Paths — Two Ways to Write an Address
There are two ways to write the location of a file or folder:
| Type | Meaning | Example |
|---|---|---|
| Absolute path | A complete address written from the root (C:\) |
C:\Users\Lee\Documents |
| Relative path | A shorthand address based on “where you are now” | Documents (when you’re in C:\Users\Lee) |
As a home-address analogy: an absolute path is writing the full address from the country down; a relative path is “two blocks up from here, then turn right” — based on your current position.
Two special symbols used in relative paths:
..: the folder one level up (the parent folder).: the current folder. Use.\to refer to it explicitly.
3. Follow Along — Time to Get Your Hands Moving
Before you begin. Use the prompt as a location indicator. A terminal window and the shell running inside it are different programs. Examples show Windows paths; do not substitute Linux commands solely because an alias has the same spelling.
3-1. Opening PowerShell
- Press the
Windows keyon your keyboard (the Start menu opens). - With it open, just type
powershell. (No need to click the search box — typing while the Start menu is open searches automatically.) - When Windows PowerShell appears in the list, press
Enter.
A blue (or black) window opens with text like this:
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
PS C:\Users\Lee>
The last line is the key. Read PS C:\Users\Lee> like this:
“PowerShell (PS) is waiting (>) for a command at the location C:\Users\Lee.”
This line is called the prompt. From now on, when this book says “check the prompt,” it means look at the path part of this line. This line is your “current location indicator.” The single secret to never getting lost in the CLI is the habit of glancing at this line every time you type a command.
Leeis an example username. Your initial location and window colors may differ. Run these commands to start from your home folder. Do not type thePS ...>prompt.cd $HOME Get-Location $PSVersionTable.PSVersion
3-2. First Command — Where Am I? Get-Location
Now let’s type a command. Type the following exactly and press Enter:
Get-Location
Result:
Path
----
C:\Users\Lee
The computer answered: “You are at C:\Users\Lee.” You just issued a command to your computer and received an answer. That’s all a CLI is — ask, and be answered.
PowerShell commands follow a Verb-Noun form. Get-Location = “Get the Location.” Thanks to this rule, you can guess the meaning of commands you’ve never seen before.
Abbreviation: there’s a shorter command with the same meaning.
pwd
Same result. pwd is an alias for Get-Location, which shows the current working location. An alias is a shorter name for the same PowerShell command; this lesson uses both formal names and aliases.
3-3. What’s Here? — Get-ChildItem
Get-ChildItem
Illustrative output (these names and timestamps are examples; your actual list will differ):
Directory: C:\Users\Lee
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2026-09-01 3:20 PM Desktop
d----- 2026-09-01 3:20 PM Documents
d----- 2026-09-02 9:15 AM Downloads
...
How to read the result — you need to be able to read this table:
- The top line
Directory: C:\Users\Lee— “this is the place being shown” (on English Windows it appears asDirectory:) d-----inMode—didentifies a directory;ais the archive attribute. Links may showl. Start by distinguishing the ordinary files and folders in this exampleLastWriteTime— when it was last modifiedName— the name
In other words, my home (C:\Users\Lee) contains folders like Desktop, Documents, and Downloads. It’s the same information you’d get by opening your folder in Explorer — the difference is you got it without a single mouse click.
Abbreviations: ls and dir do the same thing.
ls
Same result. On Windows, ls and dir are aliases for Get-ChildItem. On Linux, ls is a separate program: its options and output are different.
3-4. Moving — cd
cd is an alias for Set-Location. Return home and list the folders first.
cd $HOME
ls
If Documents actually appears as a folder in this location, try the relative path:
cd Documents
pwd
cd normally produces no output. Check that pwd shows the intended location. If Documents cannot be found, do not create a replacement folder. Ask Windows for its configured Documents path:
$documents = [Environment]::GetFolderPath('MyDocuments')
$documents
Check that the printed path is not empty and points to an existing folder. $documents is simply a name holding that path. Then run:
cd $documents
pwd
ls
An empty folder produces no listing. Read any access-denied or missing-path error before continuing. Move up one level:
cd ..
pwd
You are now in the Documents folder’s parent. With OneDrive or another drive, that parent may not be your home folder.
3-5. Jumping with an Absolute Path
First run cd $HOME and ls. If Downloads exists directly under your home folder, run:
cd Downloads
pwd
Write down your actual full path from pwd. If it were C:\Users\Lee\Downloads, the command would look like this. The Lee path is an illustration; do not paste it unchanged.
cd "C:\Users\Lee\Downloads"
Return with cd $HOME, enter cd followed by your recorded absolute path in quotes, and verify the destination with pwd. If Downloads is not under your home folder, use another existing subfolder from the listing for this exercise.
Predict first: if Downloads and Documents are siblings under your home,
cd ..\Documentsfrom Downloads reaches Documents...first refers to the parent. Execute this example only if your folder structure matches that condition.
3-6. Paths with Spaces — The Quoting Rule
This example deliberately demonstrates a space/argument error. Check your location with pwd, then enter the command below. Read the error and use pwd to verify that the location is unchanged.
cd C:\Program Files
Observed error text (layout and language vary by shell version and locale):
Set-Location: A positional parameter cannot be found that accepts argument 'Files'.
This argument error leaves your location unchanged. Use pwd to confirm.
Time to learn how to read an error. Red text is scary, but the content is helpful: “There’s no slot that accepts the argument ‘Files’.” Wait — why was Files called out separately?
PowerShell treats a space as a separator between inputs. So it understood cd C:\Program Files as three pieces: “the cd command + C:\Program + Files.” cd accepts only one destination, but it got two (C:\Program and Files), so it’s complaining about the extra one, Files.
The fix: wrap a path containing spaces in quotes to say “this is one chunk.”
cd "C:\Program Files"
Enter this command to check the location.
pwd
Example output path: C:\Program Files. Do not type an arrow or the output path as a command.
Success this time. “If a path has spaces, quote it” — one of the few rules worth memorizing today.
Let’s head back:
cd $HOME
pwd
$HOME contains the current user’s home path, so no hard-coded username is needed.
3-7. Two Techniques to Type Less
① Tab completion. First set the starting location. If your system has no C drive, use its actual program folder.
cd "C:\Program Files"
- Type
cd Comm, without pressing Enter. - Press Tab. If Common Files exists, the command completes to something like
cd '.\Common Files\'. The quote style and final backslash may vary. - Read the completed destination, press Enter, then run
pwdto confirm it.
Do not type the letters [TAB]. Press Tab repeatedly to inspect multiple candidates. Use Ctrl+C to cancel an input you do not want to run.
② Up arrow (↑). After running pwd, press ↑ once at the empty prompt. Confirm that it recalls pwd, then press Enter to run it again. History can contain other commands: read the recalled command before executing it. Key behavior can differ with PSReadLine settings.
4. Missions & Exercises
Mission — CLI Review Marathon
With no help, using only this section’s commands, do the following. (If you don’t know something, don’t scroll up right away — squeeze your memory first. That’s what builds skill.)
- Check your current location.
- Move to
C:\(the top level, the root). (Hint:cd C:\;cd \reaches the root of the current drive.) - Run
lsthere and observe which folders live at the root of Windows. Do you seeWindows,Program Files,Users? — This is the top-level map of your computer. - Use the actual Documents path found in 3-4 to go there, then verify it with
pwd. - Predict the parent of your Documents folder; run
cd ..andpwdto check. Usecd C:\to reach the root, thencd $HOMEto return home. The number of parent moves depends on the depth of the path. - Finally: write down three commands you remember from today on paper (or in Notepad). As you write, say out loud, “what did this one do again?” If the words come out, you really know it.
Your execution note: For one mission command, record “expected location → actual pwd result → cause and correction if an error occurred.” You do not need to publish your username or private folder list. If prediction and result differ, recheck the current location and whether the destination exists.
Exercises
Exercise 1. You are at C:\Users\Lee. Write two ways — absolute and relative — to get to the Downloads folder.
Exercise 2. When you’re at C:\Users\Lee\Downloads, where do you end up if you run cd .. twice?
Exercise 3. This command is deliberately incorrect. Why does it fail? Fix it so the path containing spaces is passed as one argument.
cd C:\Program Files\Common Files
Exercise 4. In Get-ChildItem output, is a line whose Mode starts with -a---- a folder or a file?
Answers & completion criteria · expand/collapse
5. Model Answers & Completion Criteria
Mission Walkthrough
1: pwd. 2: cd C:\. 3: ls. 4: inspect $documents = [Environment]::GetFolderPath('MyDocuments'), then use cd $documents and pwd. 5: cd .., pwd, cd C:\, then cd $HOME. For 6, examples are: pwd shows the current location; ls lists items; cd changes the working location.
Exercise Answers
Answer 1.
- Absolute path:
cd C:\Users\Lee\Downloads - Relative path:
cd Downloads
Answer 2. C:\Users. One cd .. takes you to C:\Users\Lee; two take you to C:\Users. If you’re unsure, type it and check with pwd — verifying is a skill too.
Answer 3. Because two spaces made PowerShell misread the path as several pieces. Wrap it in quotes:
cd "C:\Program Files\Common Files"
Answer 4. The -a---- example is an ordinary file. d indicates a directory and a the archive attribute. Other mode patterns, including links, exist; do not generalize this one example to every item.
Completion Checklist
- [ ] I can find and open PowerShell
- [ ] I can read my current location from the prompt
- [ ] I can check my location and contents with
pwdandls - [ ] I can move with
cdusing both relative and absolute paths - [ ] I can handle paths with spaces using quotes
- [ ] I’ve used Tab completion and the ↑ key
- [ ] I completed mission steps 1–6 and all 4 exercises without help
6. Common Pitfalls & Fixes
Wall 1. I ran cd and got “cannot find a positional parameter”
In this lesson’s example, the cause is typing a path with spaces without quotes (review 3-6). Wrap it: cd "Program Files".
Wall 2. I ran cd and got “Cannot find path”
This message means the path itself doesn’t exist. The causes are usually:
- A typo: like
Documants. Tab completion prevents this. - Wrong idea of where you are: there’s no such subfolder where you’re standing. Run
lsfirst to see what’s there.
Look at the path written in the error message (“Cannot find path ‘here’”), and you can see what the computer tried and failed to find. Errors aren’t enemies — they’re hints.
Wall 3. non-ASCII text looks broken (shows as □)
Your font may lack the characters, or the text encoding may be wrong. Do not skip an unreadable error. Check the terminal font settings and record the readable error text together with the command that produced it.
Wall 4. I typed a command and nothing happened
cd usually changes location without output, but silence alone does not prove success. Check the destination with pwd. Listing an empty folder is also silent. A >> prompt may mean an unfinished input, such as a missing closing quote; press Ctrl+C to cancel and try again. Errors are not always displayed in red.
Wall 5. I don’t know where I am — panic
Memorize two all-purpose incantations:
pwd— where am I right now?cd $HOME— return home
7. Summary
Commands You Learned Today
| Command (formal) | Abbreviation | What it does | Example |
|---|---|---|---|
Get-Location |
pwd |
Show current location | pwd |
Get-ChildItem |
ls, dir |
List the current folder | ls |
Set-Location |
cd |
Move | cd Documents, cd .., cd "C:\Program Files" |
New Concepts
| Concept | One-line summary |
|---|---|
| CLI vs GUI | Driving with text vs driving with pictures |
| Prompt | PS C:...> — your current-location indicator. Glance at it constantly |
| Absolute path | A complete address from the root |
| Relative path | An address from where you are now (.. = one level up) |
| Quoting rule | Wrap paths with spaces in " |
| Tab / ↑ | Completion / recall previous commands |
Instincts That Matter More Than Commands
Check whether the state matches your expectation after running a command. Use pwd to verify a move and ls to inspect a listing. Read the path and error text instead of relying on output color or silence.
One more thing — if you wondered why command names are long like Get-ChildItem, it’s thanks to the Verb-Noun rule. Rather than hundreds of short commands you’d have to memorize, the design chose long names you can guess from one rule. What was “create a folder” again? → create (New) + item (Item) = New-Item. A command you’ll meet in the next chapter.
Once every box is checked, Step 1 is complete.
Practice verification record
Current example checks, September 27, 2026. Windows PowerShell 5.1.26100.9444 and PowerShell 7.6.5 each passed 24 checks covering core commands, paths, error handling and completion candidates. The fixture’s item list, file bytes and file modification times were preserved. These were command execution, completion-engine and key-binding queries; actual Tab/↑ input, Start-menu interaction and OneDrive-redirected Documents were not tested in this run.
Historical record. The September 10 entry below records the lesson version at that time. It does not certify every later edit; distinguish its scope from the current command checks.
2026-09-10 · Executed the location, listing, relative/absolute path, and space/quoting examples on Windows 11 with Windows PowerShell 5.1.26100.9444 and PowerShell 7.6.5. Each environment passed 24 checks. Tab completion and ↑ recall/re-execution were also exercised in interactive terminals. Start-menu interaction and a OneDrive-redirected Documents environment were not part of this execution check.
References: Microsoft Get-ChildItem · Working locations · PSReadLine key bindings
ONE STEP FURTHER
Finished this lesson?
Check the completion criteria, then mark your progress.