PowerShell can feel like magic once you get the hang of it. And one of the most useful tricks in the PowerShell bag is Get-ChildItem
. This cmdlet helps you browse files and folders like a pro—whether you’re deep diving into a messy project directory or hunting down logs from last year.
Let’s break this down with some fun, practical examples you can try right now. No stress—just clean commands, clear output, and a bit of geeky joy.
Get-ChildItem
– The Basics
First off, Get-ChildItem
(or gci
for short) is used to list the contents of a directory.
Get-ChildItem
This shows the files and folders in your current location. It’s like doing dir
in CMD, but PowerShell-style.
Add a path to see items in another folder:
Get-ChildItem "C:\Projects"
Recursive Search with -Recurse
Want to search through all subfolders too? Use the -Recurse
flag. This makes Get-ChildItem
dig deep into the file system.
Get-ChildItem -Path "C:\Logs" -Recurse
You’ll get a big list of everything inside C:\Logs
and all its subfolders. Perfect for finding hidden files or checking what’s taking up space.
Here’s another example—this one finds all the text files in and under “Documents”:
Get-ChildItem -Path "C:\Users\YourName\Documents" -Filter *.txt -Recurse

Now it’s getting useful! But we can filter even more.
Filtering Files Like a Boss
Use the -Filter
parameter to pull back files that match a pattern.
- All .log files:
Get-ChildItem -Path "C:\Logs" -Filter *.log
- All .csv files, recursively:
Get-ChildItem -Path "C:\Data" -Filter *.csv -Recurse
What’s cool is that -Filter
is faster than Where-Object
because it limits the files before PowerShell processes them.
Display Only Files (No Folders)
Want to see just files? Add a little logic magic using Where-Object
:
Get-ChildItem -Path "C:\Photos" -Recurse | Where-Object { -not $_.PSIsContainer }
Let’s keep going—add a file extension filter too:
Get-ChildItem -Path "C:\Photos" -Recurse -Filter *.jpg | Where-Object { -not $_.PSIsContainer }
Voila! All JPGs, no folders, recursively listed.
Find Large Files
Sometimes you want to hunt down those big monsters hogging disk space. Try this:
Get-ChildItem -Path "C:\Downloads" -Recurse | Where-Object { -not $_.PSIsContainer -and $_.Length -gt 100MB }
This command shows files over 100 MB in C:\Downloads
and its subfolders.

Sorting It Out
You can sort and organize the results too:
Get-ChildItem -Path "C:\Videos" -Recurse |
Where-Object { -not $_.PSIsContainer } |
Sort-Object Length -Descending
This displays the largest files first. Handy when cleaning up space or prepping for backups.
Putting It All Together
Here’s a combo for real power users:
Get-ChildItem -Path "D:\Projects" -Recurse -Filter *.ps1 |
Where-Object { -not $_.PSIsContainer -and $_.LastWriteTime -gt (Get-Date).AddDays(-30) } |
Sort-Object LastWriteTime -Descending
This lists all PowerShell scripts modified in the last 30 days, newest first. Try running it in your scripts folder!

Final Words
Get-ChildItem
is simple, but super powerful. Whether you’re digging through logs, counting images, or hunting hidden junk—it’s your go-to command.
So fire up that PowerShell window, try some of these examples, and start slicing through your filesystem with style. You’ll be scripting like a ninja in no time!