Ever found yourself needing to quickly list every .pdf or .xlsx file scattered across hundreds of folders on your Windows laptop? PowerShell helps find every file with a particular extension—no matter where it’s hiding.
In this tutorial, I will explain how to find all files with extensions using PowerShell with examples.
Method 1: Find All Files with a Specific Extension (Single Extension Search)
The most straightforward scenario: you want to list all files with a known extension—say, .pdf—in a particular folder and its subfolders (for example, in C:\Users\fewli\Downloads).
Before the script, you should know:
- We’ll use
Get-ChildItem(aliased asgciordir), a versatile cmdlet for listing files and folders. - The
-Filterand-Recurseparameters let you target file types and go into all subdirectories.
Get-ChildItem -Path 'C:\Users\fewli\Downloads' -Filter *.pdf -File -Recurse
- Finds every
.pdffile within fewli’s Documents folder, searching every subfolder automatically. - The
-Filternarrows down to.pdffiles,-Fileensures directories aren’t listed, and-Recursedigs through all subfolders.
You can see the exact output in the screenshot below:

If you want just file names, add -Name at the end, like below:
Get-ChildItem -Path 'C:\Users\fewli\Downloads' -Filter *.pdf -File -Recurse -Name
Check out Find Files Older Than a Specific Date using PowerShell
Method 2: Find Files with Multiple Extensions
Sometimes, you need to find more than one file type (e.g., both .docx and .xlsx in C:\Projects\Reports\). PowerShell handles this using -Include with an array of patterns.
-Includelets you specify multiple extensions.- You must use a wildcard in the
-Path(like*) for-Includeto work recursively.
Get-ChildItem -Path 'C:\Projects\Reports\*' -Include *.docx,*.xlsx -File -Recurse
- Finds all Word and Excel files throughout the Dallas Reports project folder and subfolders.
- The wildcard (
*) after the folder lets-Includematch files in all folders, not just the root. Listing multiple extensions saves you time.
Method 3: Using Wildcards for Flexible Searches
Let’s say you’re in the Washington, D.C. office and you want every file starting with “USA_” and ending in .csv anywhere inside D:\FederalData. Wildcards are very useful.
Get-ChildItem -Path 'D:\FederalData' -Filter USA_*.csv -File -Recurse
- Finds every data file that might follow a naming scheme like
USA_Airports.csv, regardless of where it’s stored. - Wildcards (
*) simplify matching files even when names vary slightly.
Read Create SharePoint Files With REST API in Power Automate
Method 4: List Only File Names without Extensions
Some data processing workflows need base names without extensions—helpful for batch renaming or logging.
Get-ChildItem -Path 'C:\Finance\2025\Q2' -Filter *.xlsx -File -Recurse | ForEach-Object { $_.BaseName }
- Outputs only the base names of all
.xlsxfiles in the 2025 Q2 finance folder. - Clean outputs integrate easily into pipelines or other tools for further work.
Method 5: Export Search Results to CSV
Working across teams in Los Angeles? You might need to share results. Exporting to CSV is best for passing lists between tools.
Get-ChildItem -Path 'C:\Shared\HR' -Filter *.pdf -File -Recurse |
Select-Object FullName, LastWriteTime, Length |
Export-Csv -Path 'C:\HR_Files_USA.csv' -NoTypeInformation
- Gathers every PDF in the HR shared folder, with details, and saves it as
HR_Files_USA.csv. - Structured data formats like CSV play well with Excel, email, or ticketing systems.
Read Delete Files Older Than X Days With Specific Extensions Using PowerShell
Pro Tips from My Own Experience
- Filters First: Use
-Filterinstead of piping toWhere-Objectwhenever possible—it’s much faster, especially on large networks. - Automation Ready: You can make these PowerShell commands part of scheduled jobs for weekly audits in corporate environments.
- Security-Aware: When working with protected directories, run PowerShell as Administrator to avoid access errors.
- Custom Functions: If you frequently perform these searches, consider wrapping them in a custom PowerShell function.
In this tutorial, I explained different methods to find all files with an extension using PowerShell with various examples.
You may also like the following tutorials:
- PowerShell Test-Path
- How to Count Files in a Folder Using PowerShell
- Hide Return to Classic SharePoint link in SharePoint
- Download All Files From A SharePoint Online Document Library Using PnP PowerShell

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.