06-29-2011
Downloads: 404
File size: 1.1kB
Views: 2,389
Embed
 |
Search for File Content using Windows Desktop Search |
-
-
-
-
-
-
-
-
-
- $keyword1 = "PowerShell"
- $keyword2 = "Tip"
- $extension = ".docx"
- $folder = 'C:\Users\Tobias\MyDocuments\TipDocs'
-
- $objConnection = New-Object -com ADODB.Connection
- $objRecordSet = New-Object -com ADODB.Recordset
- $objConnection.Open("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")
- $objRecordSet.Open("SELECT System.ItemPathDisplay FROM SYSTEMINDEX WHERE System.FileExtension = '$extension' AND (Contains(Contents,'$keyword1') OR Contains(Contents, '$keyword2')) AND System.ItemPathDisplay LIKE '$folder\%'", $objConnection)
- if ($objRecordSet.EOF -eq $false) {$objRecordSet.MoveFirst() }
-
- while ($objRecordset.EOF -ne $true) {
- $objRecordset.Fields.Item("System.ItemPathDisplay").Value
- $objRecordset.MoveNext()
- }
illustrates how you can use PowerShell to query the desktop search engine to return paths to all docx files that contain specific keywords. You can easily adjust the script to search for videos, music or other information as well.