Looking Around: Get-ChildItem
Get-ChildItem lists what's inside a folder, with a row for each folder and file that shows what kind of thing it is, when it last changed, its size and its name, and -Force shows the hidden ones too.
Novice · PowerShell · Operating System · Updated
After this lesson you can
- List what's in a folder with Get-ChildItem and read its Mode, LastWriteTime, Length and Name columns
- Show hidden items with -Force, and only files or folders with -File or -Directory
Key takeaways
Get-ChildItemlists the folders and files inside a folder: the one you're in, or the one whose path you give it.- In the Mode column,
dmarks a folder andha hidden item. Length is a file's size in bytes. -Forceshows hidden items as well,-Fileshows only files and-Directoryonly folders.- On Windows, hidden is a setting on the file. On a Mac or Linux, a name that starts with a dot is hidden.
A friend hands you a USB stick with "everything from the trip" on it. Or a tutorial says "check that the folder has a package.json in it". Or your Downloads folder has six hundred files and you want to know what they are before you clean up. Each time the question is the same: what's really in this folder? File Explorer shows you icons, and hides some files on purpose. PowerShell gives you a list with the facts about each thing, hidden ones included when you ask.
This lesson uses the trip folder from Where Am I? Get-Location and Paths. If you don't have it yet, run that lesson's practice-folder lines first.
What's in a folder? Get-ChildItem
The things inside a folder are its children, the way a family tree puts children under their parents. Get-ChildItem gets them. With nothing after it, it lists the folder you're in; give it a path, and it lists that folder instead, without you going there:
Get-ChildItem "$HOME\terminal-practice\trip"
Directory: C:\Users\Sam\terminal-practice\trip
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/18/2026 9:40 PM day-1-beach
d---- 7/18/2026 9:40 PM day-2-old-town
d---- 7/18/2026 9:40 PM day-3-mountains
-a--- 7/18/2026 9:40 PM 228 itinerary.txt
-a--- 7/18/2026 9:40 PM 71 packing-list.txt
The first line says which folder this is. Then comes one row for each child: the three day folders first, then the two files. Your dates and times will be the moment you made the practice folder.
If the folder isn't there, PowerShell says so in red, and the message names the path it looked for, so check it for a typo: Cannot find path 'C:\Users\Sam\terminal-practice\trip\day-4-lake' because it does not exist.
Reading the four columns
Each row is a thing PowerShell knows facts about, and each column is one fact:
- Mode is a row of letters, a dash for each one that's off.
dmeans directory, PowerShell's word for a folder.a(archive) appears on ordinary files.hmeans hidden, andrread-only. - LastWriteTime is when the item last changed.
- Length is a file's size in bytes. Folders leave it blank. The pretend photos are empty files, so theirs is
0. - Name is the folder's or file's name, its extension (
.txt,.jpg) included.
These facts are more than text on the screen. Module 3 shows how to sort and filter by them: the ten biggest files, everything changed this week.
The short names for Get-ChildItem are ls, dir and gci. You'll see all three in other people's commands. (On a Mac or Linux, ls runs the system's own ls program instead, which looks different.)
Only files, or only folders
Two parameters, extra instructions written after a dash, narrow the list. -File keeps only the files, and -Directory only the folders:
Get-ChildItem "$HOME\terminal-practice\trip" -Directory
Directory: C:\Users\Sam\terminal-practice\trip
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/18/2026 9:40 PM day-1-beach
d---- 7/18/2026 9:40 PM day-2-old-town
d---- 7/18/2026 9:40 PM day-3-mountains
What's hidden: -Force
Some files are hidden so you don't change them by accident: settings, an app's private data. Your own home folder has a hidden AppData folder where apps keep their settings. The practice folder has a hidden file too, and -Force shows it:
Get-ChildItem "$HOME\terminal-practice\trip" -Force
Directory: C:\Users\Sam\terminal-practice\trip
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 7/18/2026 9:40 PM day-1-beach
d---- 7/18/2026 9:40 PM day-2-old-town
d---- 7/18/2026 9:40 PM day-3-mountains
---h- 7/18/2026 9:40 PM 40 budget.txt
-a--- 7/18/2026 9:40 PM 228 itinerary.txt
-a--- 7/18/2026 9:40 PM 71 packing-list.txt
There's the trip budget, with an h in its Mode. A hidden file is an ordinary file with one setting switched on, and the practice-folder lines switched it on with Set-ItemProperty. Hidden isn't secret: anyone who adds -Force sees it.
On a Mac or Linux, and in Terminal Quest, hidden works differently: a name that starts with a dot, such as .crab-shell, is hidden, and -Force shows it the same way. In Windows PowerShell 5.1 the Mode column has six letters (d-----) instead of five.
Try it. List your Downloads folder with Get-ChildItem "$HOME\Downloads". Which row is the biggest file? Then add -Force and see whether anything new appears.
Try it in the terminal
Terminal Quest: The Lighthouse, goal 2: played right on the lesson page.
You've found out where you are. Now look around the lighthouse and see what's here.
Check yourself
2 questions to try on the lesson page.
So what
Before you change anything in a folder, look first. Get-ChildItem shows you every child and its facts, hidden ones too when you ask, and that habit saves you from deleting or overwriting the wrong thing later.