Use the minus sign in Windows Search to exclude a word, use path: or folder filters to exclude locations, and use settings or policies to exclude indexed content. File Explorer and PowerShell use different syntax, and Microsoft Defender uses separate exclusion lists. If you use the wrong method, searches return the same unwanted files or, worse, you hide the wrong items. This guide shows the exact exclusion syntax by tool and when each one applies.

What you’ll need

  • Windows Search or File Explorer for local file and folder searches.
  • PowerShell for text filtering with Select-String.
  • Access to indexing settings if you want content to stay out of search results.
  • A clear target: a word, a file path, a folder, or indexed content.
What “exclude” means in Windows search
Windows settings shows excluded folders in the search menu

“Exclude” can mean three different things in Windows: leave a term out of the query, leave a folder or path out of the result set, or keep content out of the index so it never appears in indexed search. Those are different tools and different syntax. If one method does nothing, you likely picked the wrong search surface.

Term exclusion, path exclusion, and content exclusion

Term exclusion is about search language. Path exclusion is about location. Content exclusion is about indexing. Windows Search and File Explorer handle local file discovery and indexed content; PowerShell Select-String filters strings and files; Defender exclusions change antivirus scanning, not search results.

Which exclusion method should you use?

Which exclusion method should you use?
Windows Defender settings show the Exclusions menu and add-exclusion options

Match the tool to the item you want removed. For a word in a query, use Windows Search syntax or PowerShell text filtering. For a folder, narrow the location in File Explorer or path filters. For content that should never appear in indexed results, change indexing settings instead of forcing a query to ignore it.

Local search, PowerShell, and index settings

  1. Use File Explorer when you want to search a folder or drive and keep the scope narrow.
  2. Use PowerShell Select-String when you want to filter text with a match or no-match condition.
  3. Use Indexing Options when you need file content or properties to stay out of Windows Search results.
  4. Use Defender exclusions only for antivirus scanning exceptions, not for search cleanup.

Two quick scenarios

Say your Downloads folder contains a large number of files and you only want PDFs from one subfolder. Limit the search to that path first, because a term exclusion will not stop unrelated folders from appearing if they are still in scope.

Suppose a log file contains both error and warning lines, but you only want the lines that do not match warning. That is a PowerShell filtering job, not a File Explorer search job.

Which Windows search tool supports exclusion?

Windows Search, File Explorer, PowerShell Select-String, and Microsoft Defender all support exclusion in different ways. The key is that they exclude different things. Windows Search and File Explorer are about local discovery and index scope, PowerShell filters text, and Defender excludes folders from scanning. Here is the fast map.

Tool Exclusion syntax What it excludes Supports NOT-style queries? Common failure mode
Windows Search / File Explorer - in a query, plus path: and folder/location filters Query terms, search scope, indexed locations, and visible file set Sometimes, for query terms Typing a PowerShell-style switch that File Explorer does not understand
PowerShell Select-String -Exclude and -NotMatch File names or paths with -Exclude; text lines with -NotMatch Yes Using -NotMatch as if it were a direct file-search switch without matching input type
Windows Defender Exclusion list in Defender settings Antivirus scanning targets, such as folders No Expecting a scan exclusion to remove items from Windows Search results

How do you exclude a string in PowerShell?

Use Select-String when you need text filtering. Microsoft describes it as similar to grep and findstr.exe. It supports -Exclude and -NotMatch, and it can display text that does not match a pattern. The key is to match the switch to the input type you are searching. (Microsoft Learn)

Use the right switch for the right input

  1. Search files and strings with Select-String, not File Explorer.
  2. Use -Exclude to skip file names or paths that match a pattern.
  3. Use -NotMatch when you want the output to keep only lines that do not match the pattern.
  4. Check whether the command is reading text input or files before you run it.

Examples that fit the command

Select-String -Path .\logs\*.txt -Pattern "warning" -Exclude *.bak skips matching backup files. For line filtering, pipe text into Select-String -Pattern "warning" -NotMatch. That second form works on input text, not as a file exclusion switch.

What to do if nothing changes

If the command still returns the same output, the likely issue is context. -NotMatch filters text lines; it does not tell File Explorer to hide files. If you are searching files, use -Exclude for paths or switch to a path-limited search first.

How do you exclude files or folders from search?
Windows settings shows excluded folders for search indexing

For local file search, the cleanest approach is usually to narrow scope rather than fight the query syntax. File Explorer searches folders and files, and the result set changes depending on whether the location is indexed. If the location is not indexed, searches can be slower and behavior can differ from local indexed folders.

Limit the search scope first

  1. Open the specific folder or drive you want to search in File Explorer.
  2. Run the search from that location instead of from “This PC.”
  3. If a folder keeps appearing, remove it from the search scope rather than adding term exclusions.
  4. Use path: filters when the search box supports them.

Check indexed locations

Windows Search uses indexing for local content. The Windows Search index stores indexed file metadata and content, which speeds up results. Its schema can control whether a property is included in the search engine, and it supports predicate-based queries such as System.Title equals a value. If you change what gets indexed, you may need to rebuild the index afterward, which can take time and temporarily change results.

Network drives need extra care

Network drives often search differently from local drives because they may not be fully indexed by default. If a shared folder ignores your exclusion attempt, check whether the location is indexed at all. A term filter will not fix a scope problem, and a scope filter will not change indexing on a remote share.

How do you exclude content from Windows Search index?

Use index settings when the goal is to keep certain file content or properties out of Windows Search results. This is different from hiding a file from view or skipping a folder in one search. Windows Search can use full-text and predicate-based queries, and property settings can control whether data is included in the index.

Change indexing, not the query

  1. Open Settings > Privacy & security > Searching Windows or the classic indexing options on your version of Windows.
  2. Choose which locations Windows Search should index.
  3. Exclude the folder or content source you do not want searchable.
  4. Rebuild the index if the old results keep showing up after the change.

Know the tradeoff

The Windows Search schema includes a searchInfo element for Windows 7 and later, and the default maxSize is 512 bytes on the Microsoft schema page. That tells you indexing is property-driven, not magic. Excluding content can cut down on irrelevant results, but it can also make that content harder to find later.

Common mistakes

The most common failure is using the wrong exclusion type. A PowerShell switch will not change File Explorer results, and a Defender exclusion will not change Windows Search. Another common miss is assuming a network drive behaves like an indexed local folder.

What goes wrong and how to fix it

  • Wrong tool: Use PowerShell for text filtering, File Explorer for local file scope, and Windows Search settings for indexed content.
  • Wrong syntax: If a query term is not excluded, try the search box syntax for that tool instead of copying PowerShell.
  • Wrong expectation: Defender exclusions stop scanning, not search results.
  • Wrong location: Network drives may need separate indexing or a narrower folder scope.

A common first-timer mistake is expecting one exclusion command to work everywhere. For example, a search in a shared drive on a server may keep returning the same folder because the drive is not indexed the same way as a local folder. In that case, fix the scope or the index, not the query term.

Keep reading

Frequently asked questions

How to search to exclude something

In File Explorer, start in the folder you want and add the filter that removes the item type or path you do not want. In PowerShell, use Select-String with -NotMatch for text lines or -Exclude for file names and paths.

Use the minus sign in Windows Search for query terms. In PowerShell, use -NotMatch when you want output that does not match a word inside text, and remember that this filters lines, not Explorer results.

How to exclude search results

Decide whether you want fewer results because of the query, the folder scope, or the index. Query exclusions change the search string. Scope exclusions change where Windows looks. Index exclusions change what Windows can return at all.