Open Control Panel > opt Large Icons > Indexing Options > Click Modify, then Show all locations > Locate your OneDrive directory and deselect the subfolders you want to exclude > Apply/ok
How do i exclude OneDrive subfolders from my file explorer searches
How do i exclude OneDrive subfolders from my file explorer searches
Windows for business | Windows Client for IT Pros | User experience | Other
3 answers
Sort by: Most helpful
-
-
Lily-T 240 Reputation points Microsoft External Staff Moderator
2025-06-17T03:16:15.9733333+00:00 Dear @Fuglem, Mark
Thank you for reaching out Q&A Forum!
We understand that you require a guide on how to exclude OneDrive subfolders from your File Explorer searches.
Based on our testing environment, please try the following steps:
- Click Window Logo (Start Button) > Go to Settings > Select Privacy & Security.
- Scroll down and select Searching Windows.
- Select Advanced indexing options.
- The Indexing Options window will open > choose Modify button > Go to your OneDrive folders and untick the subfolders that you want to exclude > click OK and then Close.
- The options you exclude will be displayed as below.
Please visit the link for your reference: Search indexing in Windows - Microsoft Support
If you have any questions, please feel free to contact us at your convenience.
Understanding your use case in more detail will help us recommend the most efficient and compatible solution.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
Fuglem, Mark 5 Reputation points
2025-06-23T12:34:25.2733333+00:00 Because I don't have admin priviledges and for other reasons, I finally went with a power shell script (a simplified version follows). This works very well and is very fast. Thanks.
File C:\Folder1\SearchPDFsWithTwoAuthors.ps1
Find all pdf's with Author1 and Author2 and write to a text file
Run the following in Power Shell
cd ‘C:\Folder1\’
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\SearchTwoAuthorsPDFs.ps1
$rootDir = "C:\Folder1"
$outputFile = "C:\Folder1\SearchResults.txt"
$fileExtension = "*.pdf"
$keyword1 = "Author1"
$keyword2 = "Author2"
$writer = [System.IO.StreamWriter]::new($outputFile, $false, [System.Text.Encoding]::UTF8)
Directories to skip (any subfolder of these is also skipped)
$dirsToSkip = @(
"C:\Folder1\SubFolder1", "C:\Folder1\OneDrive"
)
Normalize skip paths (lowercase + no trailing backslash)
$dirsToSkipNormalized = $dirsToSkip | ForEach-Object { ($_ -replace '\+$', '').ToLower() }
Get directories recursively, suppress errors
$directories = Get-ChildItem -Path $rootDir -Directory -Recurse -ErrorAction SilentlyContinue | Where-Object {
$dirPath = $_.FullName.ToLower() -not ($dirsToSkipNormalized | Where-Object { $dirPath.StartsWith($_) })
}
foreach ($dir in $directories) {
# Only search files in the current directory $results = Get-ChildItem -Path $dir.FullName -File -Filter $fileExtension -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "*$keyword1*" -and $_.Name -like "*$keyword2*" } foreach ($result in $results) { $message = "$($result.Name) in $($result.DirectoryName)" Write-Host $message -ForegroundColor Green $writer.WriteLine($message) }
}
$writer.Close()