PowerShell Find All Files With Extension

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 as gci or dir), a versatile cmdlet for listing files and folders.
  • The -Filter and -Recurse parameters let you target file types and go into all subdirectories.
Get-ChildItem -Path 'C:\Users\fewli\Downloads' -Filter *.pdf -File -Recurse
  • Finds every .pdf file within fewli’s Documents folder, searching every subfolder automatically.
  • The -Filter narrows down to .pdf files, -File ensures directories aren’t listed, and -Recurse digs through all subfolders.

You can see the exact output in the screenshot below:

PowerShell Find All Files With Extension

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.

  • -Include lets you specify multiple extensions.
  • You must use a wildcard in the -Path (like *) for -Include to 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 -Include match 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 .xlsx files 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 -Filter instead of piping to Where-Object whenever 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:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App