By Richard Igwegbu
Cloud Engineer & Founder, Unix Training Academy
Have you ever found yourself struggling to locate an Excel file on your laptop — especially when you’ve forgotten the filename and have several external drives connected?
You’re not alone.
In this post, I’ll walk you through a step-by-step method using PowerShell to search across all your drives for any .xls
or .xlsx
files and export the results to a CSV file you can easily browse in Excel.
Why Use PowerShell?
While Windows File Explorer works for basic searches, it’s often slow and may miss deeply nested files. PowerShell, however, gives you a fast, scriptable way to scan multiple drives and generate a full report.
Step-by-Step Guide: Search & Export Excel Files
1. Launch PowerShell as Administrator
Press
Windows + X
Click on Windows PowerShell (Admin)
2. Create a Folder to Store the Output
You can manually create a folder in C:\Temp
or run this in PowerShell:
New-Item -ItemType Directory -Path "C:\Temp"
3. Run This PowerShell Script
Copy and paste this into PowerShell:
$drives = @(“C:\”, “D:\”, “E:\”, “G:\”) # Include your connected drives
$output = "C:\Temp\Excel_Files_Found.csv"
Get-ChildItem -Path $drives -Recurse -Include *.xls, *.xlsx -ErrorAction SilentlyContinue |
Select-Object Name, FullName, LastWriteTime |
Export-Csv -Path $output -NoTypeInformation
Write-Output “Search complete. File saved to $output”
This will:
Search all specified drives
Find all Excel files
Save the name, full path, and last modified date to a CSV file
Common Error: Path Too Long
If you see:
PathTooLongException: The specified path, file name, or both are too long...
Don’t worry — this just means a few files are too deeply nested. Most files will still be captured and saved.
Optional Fix:
Enable long path support:
Press
Windows + R
, typegpedit.msc
, and press Enter.Navigate to:
Computer Configuration > Administrative Templates > System > Filesystem
Open Enable Win32 long paths, set to Enabled, and restart your PC.
Bonus: Filter for Recently Modified Files
Want to narrow the results to only the last 12 months?
Use this variation:
Get-ChildItem -Path $drives -Recurse -Include *.xls, *.xlsx -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-365) } |
Select-Object Name, FullName, LastWriteTime |
Export-Csv -Path $output -NoTypeInformation
Where to Find Your Results
Once the script finishes, open:
C:\Temp\Excel_Files_Found.csv
Open it in Excel to see a list of:
File names
Full file paths
Last modified dates
You can sort or filter the list as needed.
Final Thoughts
Whether you’re managing cloud infrastructure or just trying to recover a lost budget spreadsheet, PowerShell can save you time and stress.
I use scripts like these often during IT audits, training labs, and personal cleanup tasks — and they never disappoint.
📌 More Resources
Visit Unix Training Academy for live hands-on training.