Skip to content

Instantly share code, notes, and snippets.

@GluTbl
Last active October 10, 2025 04:00
Show Gist options
  • Save GluTbl/40db283e14a54308dfc497c59c9c9a92 to your computer and use it in GitHub Desktop.
Save GluTbl/40db283e14a54308dfc497c59c9c9a92 to your computer and use it in GitHub Desktop.
[Search files in WIndows] #powershell
function Find-Exact-FileWithProgress {
param (
[string] $BasePath,
[string] $FileName
)
$files = Get-ChildItem -Path $BasePath -Recurse -File -ErrorAction SilentlyContinue
$total = $files.Count
$counter = 0
foreach ($f in $files) {
$counter++
Write-Progress -Activity "Searching in $BasePath" -Status "$counter / $total" -PercentComplete (($counter / $total) * 100)
if ($f.Name -eq $FileName) {
Write-Output $f.FullName
}
}
Write-Progress -Activity "Searching in $BasePath" -Completed
}
#Find-Exact-FileWithProgress -BasePath "C:\Path\To\Your\Folder" -FileName "file.dll"
function Find-Match-FileWithProgress {
param (
[string] $BasePath,
[string] $Pattern
)
$files = Get-ChildItem -Path $BasePath -Recurse -File -ErrorAction SilentlyContinue
$total = $files.Count
$counter = 0
foreach ($f in $files) {
$counter++
Write-Progress -Activity "Searching in $BasePath" -Status "$counter / $total" -PercentComplete (($counter / $total) * 100)
if ($f.Name -like $Pattern) {
Write-Output $f.FullName
}
}
Write-Progress -Activity "Searching in $BasePath" -Completed
}
#Find-Match-FileWithProgress -BasePath "C:\Users\v\Downloads\tmp" -Pattern "*.dll"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment