3

Windows Search is built on Windows Index settings (shown below).

I need to make a powershell script (so everyone here can just run the script to get configured), to :

  • Add appro dir struct to the list of indexed locations
  • Set a list of visual studio file types to index file contents

What would such a script look like?

enter image description here enter image description here

Jonesome Reinstate Monica
  • 6,618
  • 11
  • 65
  • 112
  • Try adapting [Powershell Tackles Windows Desktop Search](https://powertoe.wordpress.com/2010/05/17/powershell-tackles-windows-desktop-search/) article, probably using [MSDN: Windows Search API](https://msdn.microsoft.com/en-us/library/bb266516(v=vs.85).aspx). – wOxxOm Aug 18 '16 at 21:53
  • 1
    @Jonesome Did you ever succeed in doing this, if so, could you share it as an answer to your own question? – Peter B Aug 07 '19 at 07:34
  • @PeterB I never solved this via powershell, so unfortunately do not have a solve to share. – Jonesome Reinstate Monica Aug 07 '19 at 22:05

1 Answers1

1

It seems that File Types can be added and changed via the registry.

To add a new File Type and set it to "Properties and File Contents" using "Plain Text Filter", create a key at: Computer\HKEY_CLASSES_ROOT[.extensionYouWantToAdd]\PersistentHandler

Set the (Default) value to

Type: REG_RZ, Data: {5E941D80-BF96-11CD-B579-08002B30BFEB}

I'm not sure, but I'd venture a guess that the GUID specifies that the plain text filter should be used.

I imagine that it is also possible to change the indexed locations in a similar manner.

I figured this out by adding new file types manually and then searching the registry and to find the changes that were made. I have confirmed this works and also found this article that recommends the same technique: https://www.itprotoday.com/windows-78/how-can-i-include-specific-file-type-file-system-search-under-windows-xp

For my case I will be editing the registry via other methods, but it seems this is possible via Powershell also as outlined here: https://blog.netwrix.com/2018/09/11/how-to-get-edit-create-and-delete-registry-keys-with-powershell/

Once you have changed the registry, you will need to tell the index to rebuild. (Covered here: How to rebuild Windows Search Index by using PowerShell?)

Harlan
  • 141
  • 8
  • FYI, in my test the index updated itself upon rebooting even without asking it to rebuild. – Harlan Sep 11 '19 at 07:57
  • According to Microsoft, rebuilding the index is not necessary - all you have to do is log out and log back in: https://support.microsoft.com/en-us/help/309173/using-the-a-word-or-phrase-in-the-file-search-criterion-may-not-work – Harlan Oct 18 '19 at 22:53