Skip to content

Instantly share code, notes, and snippets.

@SvenAelterman
Last active October 31, 2021 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SvenAelterman/3b767320cd535e06ea33b3398b4e39c9 to your computer and use it in GitHub Desktop.
Save SvenAelterman/3b767320cd535e06ea33b3398b4e39c9 to your computer and use it in GitHub Desktop.
PowerShell to query local Windows Search index (e.g., for Visio shapes)
$contents = "Virtual"
$sql = "SELECT System.ItemName, System.ItemUrl FROM SYSTEMINDEX WHERE Contains(*,'$($contents)') AND System.ItemType='.VSSX'"
$Provider = "Provider=Search.CollatorDSO;Extended Properties=’Application=Windows’;"
$adapter = new-object system.data.oledb.oleDBDataadapter -argument $sql, $Provider
$ds = new-object system.data.dataset
if ($adapter.Fill($ds)) { $ds.Tables[0] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment