A PowerShell script to prevent Windows from excluding folders to being indexed.
Windows Search uses a background service to index files for faster lookup.
For performance reasons, Microsoft has recently started to automatically exclude folders detected as repositories (such as Git or SVN) from indexing.
However, a bug causes not just the .git or .svn folders to be excluded, but their parent folder as well.
This can be problematic for developers who use the repository folder as their working directory: any documents stored there will no longer be indexed and will not appear in Windows Search results.
Fortunately, there's a workaround. If a .git or .svn folder is already present in the list of excluded folders, then the parent folder will no longer be automatically excluded.
But manually adding each of these hidden folders to the exclusion list is tedious.
This script was created to automate the process: it recursively scans the selected volume and adds every folder starting with a dot (.) to the Windows Search exclusion list.
The inclusion/exclusion list is stored in a protected key of the Windows Registry.
Therefore, running the script as Administrator is required — but not sufficient. You must also:
In regedit, navigate to:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules
Right-click → Permissions → Grant Full Control to the Administrators group.
Open Windows-Search.ps1 in Notepad and edit the line:
$volumeLetter = "E:\"Change the drive letter if necessary.
Open PowerShell as Administrator and execute:
.\Windows-Search.ps1This script helps ensure your development files remain visible and searchable in Windows.
This script modifies sensitive keys of the Windows Registry and should be used with caution.
Ensure you have a backup or system restore point before proceeding.
Use at your own risk — the author is not responsible for any damage or data loss resulting from its use.