Best way to search a specific file type across multiple windows network drives containing about 1 million file names?

Rick Amann 20 Reputation points
2025-12-01T22:36:22.6866667+00:00

Need a fast way to search filenames (*.prt) across multiple windows network drives and record the full path and filename in a single .txt file. Network drives contain about 6 Million files, results will be just under 1 Million filenames. The result text file can then be quickly searched using web tools.

Windows for business | Windows Server | Performance | System performance
{count} votes

Answer accepted by question author
  1. VPHAN 9,355 Reputation points Independent Advisor
    2025-12-01T23:46:18.4633333+00:00

    Good morning Rick Amann,

    For this volume, use a PowerShell script with parallel processing to minimize runtime. Save the following as search_prt.ps1 and run it in an elevated PowerShell window:

    $drives = @("X:", "Y:", "Z:") # Replace with your network drive letters or UNC paths

    $output = "C:\temp\prt_results_$(Get-Date -Format 'yyyyMMddHHmmss').txt"

    $errorLog = "C:\temp\search_errors.log"

    foreach ($drive in $drives) {

    Get-ChildItem -Path $drive -Filter *.prt -Recurse -ErrorAction SilentlyContinue -ErrorVariable accessErrors | 
    
    ForEach-Object -Parallel {
    
        $_.FullName | Out-File -FilePath $using:output -Append -Encoding UTF8
    
    } -ThrottleLimit 10  # Adjust based on network/server load
    
    if ($accessErrors) { $accessErrors | Out-File $errorLog -Append }
    

    }

    Key optimizations:

    -ThrottleLimit controls concurrent threads to prevent network saturation.

    -ErrorAction SilentlyContinue with -ErrorVariable logs permission/access issues without stopping.

    Appends results directly to the output file to avoid memory overload.

    For UNC paths, ensure the script runs under an account with read access to all shares. If PowerShell execution is restricted, run Set-ExecutionPolicy Bypass -Scope Process first. The output will be a plain text file with one full path per line, suitable for web tools.

    I hope you've found something useful here. If it helps you get more insight into the issue, it's appreciated to ACCEPT ANSWER then. Should you have more questions, feel free to leave a message. Have a nice day!

    VP

    You found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.