Get-ChildItem Examples: List and Find Files in PowerShell
Get-ChildItem is the cmdlet behind ls and dir. On its own it lists a folder, but a few parameters turn it into a decent file search.
Basics
Run it with a path, or with nothing to use the current folder.
Get-ChildItem
Get-ChildItem C:\Users\Public
Find files by name
-Filter is fast and takes a simple wildcard. -Recurse goes into subfolders. -File and -Directory limit the type.
Get-ChildItem -Recurse -Filter *.log
Get-ChildItem -Directory
Sort by size or date
Pipe the result to Sort-Object and Select-Object. This finds the biggest files in a folder tree.
Get-ChildItem -Recurse -File | Sort-Object Length -Descending | Select-Object -First 10 Name, Length
Practice it for real. shellreps has hands-on PowerShell labs that run in your browser, no install. The first one is free, no signup. The terminal mimics PowerShell syntax so the habits carry over, though it isn't Microsoft's PowerShell itself.