searchutils
Scripts and techniques to search for keywordss in Office documents, and leverage the Windows Indexing Service for quick file content searches.
Usage
Search-OfficeDocuments
Using the Office COM Objects this script will open Word and Excel files to search for the provided keyword. It will also look if the filename itself matches the keyword.
gci -r * | Search-OfficeDocuments | ft
Invoke-WindowsSearch
This script directly connects to the Windows Search database and queries for the provided keyword.
Invoke-WindowsSearch password
Long Path Names
Paths over 256 chars will produce errors, to enable long path names see the following Microsoft article and/or follow these steps:
- Start the registry editor (regedit.exe)
- Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
- Double-click LongPathsEnabled
- Set to 1 and click OK
- Reboot
Learn more
Some more useful information can be found below:
- Windows Search Samples - https://github.com/microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/winui/WindowsSearch
- Excel COM Object: https://docs.microsoft.com/en-us/office/vba/api/excel.range.findnext
- Word COM Object: https://docs.microsoft.com/en-us/office/vba/api/word.find.execute
- Windows 10 Pro 22H2 - Enable Win32 long path doesn't work