Locate filesystem items by filename, extension, directory name, and path.

Sheet: 03 of 25 | Platform: Windows 10/11 | Shell: PowerShell 7.x and Windows PowerShell 5.1 (unless marked otherwise) | Editorial review: November 24, 2026

PowerShell cheat sheet index

Examples use the MGU project root and illustrative staging, backup, and download paths. Replace them with existing, approved paths as needed. Unless explicitly marked as a continuation, examples are independent. Read commands before running them; commands that write or modify files can change existing data.

Quick commands

1. Find a specific filename

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter 'index.html'

2. Find files with a partial name

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File -Filter '*powershell*'

3. Find directories matching a name

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -Directory -Filter '*articles*'

4. Find several extensions

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File |
    Where-Object { $_.Extension -in '.html', '.md', '.txt' }

5. Find paths containing a folder name

Get-ChildItem -LiteralPath 'C:\MGU' -Recurse -File |
    Where-Object { $_.FullName -like '*\encyclopedia\*' }

6. Check an exact expected file

Test-Path -LiteralPath 'C:\MGU\index.html' -PathType Leaf

Operational notes

-Filter is generally more efficient for a single filename pattern than filtering every returned object. -LiteralPath protects paths containing wildcard characters. A filename match is not a content match.

Official documentation