If you’re a Windows administrator, DevOps engineer, or IT professional, you’ve probably needed to locate a folder buried deep within a directory structure. Manually doing this is really tough. So, you can use PowerShell for this.
In this tutorial, you’ll learn how to find a folder by name using PowerShell, step‑by‑step with real examples.
The Core Cmdlet: Get-ChildItem
The main PowerShell command for finding files and folders is Get-ChildItem, often abbreviated as gci. It lists items (files and directories) in a specified path.
Basic Syntax
Here is the basic syntax:
Get-ChildItem -Path "C:\Path\To\Search" -Directory -Recurse -ErrorAction SilentlyContinue-Path— The directory you want to search.-Directory— Ensures only folders (not files) are returned.-Recurse— Searches all subdirectories.-ErrorAction SilentlyContinue— Suppresses access‑denied errors.
Check out Create a Folder with Today’s Date and Copy Files to it using PowerShell
Example 1: Find a Folder by Exact Name
If you know the exact folder name, you can use the -Filter parameter for a fast, efficient search:
Get-ChildItem -Path "C:\Users" -Directory -Filter "Documents" -RecurseThis command searches under C:\Users for any folder named Documents, recursively checking all subfolders.
Here is the exact output in the screenshot below:

✅ Tip: The
-Filterparameter is processed by the filesystem provider, making it faster than usingWhere-Object.
Example 2: Find Folders by Partial Name (Wildcard Search)
Sometimes, you only remember part of the folder name. In that case, use a wildcard character (*):
Get-ChildItem -Path "C:\Projects" -Directory -Recurse -Filter "*Archive*"This finds all folders with “Archive” anywhere in their name — e.g., OldArchive, Archive2025, or ProjectArchive.
Alternatively, you can use Where-Object for more advanced pattern matching:
Get-ChildItem -Path "C:\Projects" -Directory -Recurse |
Where-Object { $_.Name -like "*Archive*" }Check out Set Folder Permissions Using PowerShell
Example 3: Case‑Insensitive Folder Search
PowerShell searches are case‑insensitive by default on Windows, but if you want to enforce case sensitivity (useful in cross‑platform environments), you can do this:
Get-ChildItem -Path "/mnt/data" -Directory -Recurse |
Where-Object { $_.Name -clike "*Archive*" }Here, -clike performs a case‑sensitive comparison.
Example 4: Find Folders by Name and Modified Date
To narrow down results, you can combine name and date filters like the below PowerShell script.
Get-ChildItem -Path "C:\Logs" -Directory -Recurse |
Where-Object { $_.Name -like "*Backup*" -and $_.LastWriteTime -gt (Get-Date).AddDays(-7) }This finds all folders with “Backup” in the name that were modified within the last 7 days.
Example 5: Export Folder Search Results to a CSV File
For documentation or auditing purposes, you might want to export your search results:
Get-ChildItem -Path "D:\Data" -Directory -Recurse -Filter "*Reports*" |
Select-Object FullName, LastWriteTime |
Export-Csv -Path "C:\Temp\ReportFolders.csv" -NoTypeInformationThis creates a CSV file listing all folders containing “Reports” along with their last modified date.
Check out Create Folder Structure from CSV using PowerShell
Example 6: Find Folders on a Remote Computer
With PowerShell remoting, you can perform folder searches on remote systems:
Invoke-Command -ComputerName "Server01" -ScriptBlock {
Get-ChildItem -Path "C:\Logs" -Directory -Recurse -Filter "*Archive*"
}Make sure PowerShell Remoting is enabled on the target machine (Enable-PSRemoting -Force).
Example 7: Using Get-Item and Test-Path for Specific Folder Checks
If you just want to check whether a specific folder exists, use Test-Path:
Test-Path "C:\Projects\Archive2024"Returns True if the folder exists, otherwise False.
Or retrieve the folder’s details directly:
Get-Item "C:\Projects\Archive2024"Example 8: Create a Reusable PowerShell Function
If you frequently search for folders, wrap your logic into a reusable function:
function Find-FolderByName {
param(
[Parameter(Mandatory=$true)][string]$Path,
[Parameter(Mandatory=$true)][string]$Name
)
Get-ChildItem -Path $Path -Directory -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "*$Name*" }
}Usage:
This is how you can use it:
Find-FolderByName -Path "C:\Projects" -Name "Archive"This function can be saved in your PowerShell profile for everyday use.
Read Create Multiple Folders in PowerShell
Example 9: Find Folders and Perform Actions on Them
You can combine folder search with additional actions, such as copying or deleting:
Get-ChildItem -Path "C:\Data" -Directory -Recurse -Filter "*Temp*" |
ForEach-Object {
Remove-Item $_.FullName -Recurse -Force
}⚠️ Warning: Always test with -WhatIf before deleting:
Remove-Item $_.FullName -Recurse -Force -WhatIfIn this tutorial, I explained how to find folders by name in PowerShell by providing various examples.
- Use
Get-ChildItemto find folders by name - Filter by partial names, dates, and attributes
- Export results to CSV
- Search remote systems
- Optimize performance
You may also like the following tutorials:
- Create a Folder with the Current Date using PowerShell
- Create Folders with Year, Month, and Day Using PowerShell
- Create a Shortcut to a Folder Using PowerShell
- Find and Remove Empty Folders Using PowerShell
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.