Problem Querying Windows Search Index on VM windows instance

0

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 runs fine on my computer but I try to run the same query on virtual instance of windows on google cloud it gives me following error:

I read on stack overflow that it may be because of query syntax but it should also not work on computer.

Error: Exception calling "Fill" with "1" argument(s): "IErrorInfo.GetDescription failed with E_FAIL(0x80004005)." At C:\Users\raghib_amanat\Desktop\Windows Explorer Wrapper\temp_unlimited_number_of_documents.ps1:20 char:5 if ($connector.fill($dataset)) CategoryInfo : NotSpecified: (:) [], MethodInvocationException FullyQualifiedErrorId : OleDbException

sql
powershell
windows-search
asked on Stack Overflow Sep 29, 2020 by Muhammad Raghib • edited Sep 29, 2020 by Muhammad Raghib

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0