I have written this shell script to query the windows search index.
$sql = "SELECT System.ItemName, System.ItemPathDisplay, SYSTEM.FileOwner, System.ItemType
FROM SYSTEMINDEX
WHERE (SCOPE = 'C:\Users\Raghib\Desktop\1001') AND (CONTAINS(System.Search.Contents,'*Langevin*') OR CONTAINS(System.FileName,'*Langevin*')
OR CONTAINS(System.FILEOWNER,'*Langevin*'))"
$provider = "provider=search.collatordso;extended properties='application=windows';"
$connector = new-object system.data.oledb.oledbdataadapter -argument $sql, $provider
$dataset = new-object system.data.dataset
if ($connector.fill($dataset))
{
$dataset.tables[0] | select-object System.ItemName, System.ItemPathDisplay,
SYSTEM.FileOwner, System.ItemType | format-table -autosize *
}
It returns all the metadata of the file but I want to get all the contents of the file also. Is there any way to do so?
Here is the link to SYSTEMINDEX column properties: https://learn.microsoft.com/en-us/previous-versions//ff521735(v=vs.85)?redirectedfrom=MSDN
According to Microsoft documentation System.Search.Contents property cannot be retrived.
see: https://learn.microsoft.com/en-us/windows/win32/properties/props-system-search-contents