Exclude PSTs from Windows Desktop Search Index with PowerShell + Microsoft.Search.Interop

78 views Asked by At

I have a dozen large historical Outlook PSTs that are indexed with a third-party tool (X1). I am trying to avoid them being added to the Windows Desktop Search due to performance and stability issues that occur when the index has millions of items. I don't have them open in Outlook, so normally I wouldn't expect them to be crawled and indexed, but because the third-party tool creates Outlook profiles corresponding to each PST, it appears that WDS is still crawling and indexing them, even when they are never open in Outlook.

I am trying to use Microsoft.Search.Interop to manually exclude them from the index. The documentation for the interface is limited, particularly by way of examples. I've written the following code (simplified example for one PST) that I think should exclude these PSTs, but they are still getting crawled.

Any ideas how to troubleshoot or narrow the issue? Any Microsoft.Search.Interop gurus out there?

Add-Type -path "Microsoft.Search.Interop.dll"
$sm = New-Object Microsoft.Search.Interop.CSearchManagerClass
$catalog = $sm.GetCatalog("SystemIndex")
$crawlman = $catalog.GetCrawlScopeManager()
$crawlman.AddUserScopeRule("mapi16://{S-1-5-21-96414999-1499730031-444732941-29377}/archive2022($17228913)",$false,$true,$null)
$crawlman.SaveAll()

I've also tried variations like AddDefaultScopeRule instead of AddUserScopeRule, and using wildcards in the mapi16:// URL pattern. When I do add wildcards (for example, *, .*, (*), or (.*) after the PST name for the $guidstring), I don't see the rules actually appear in the ruleset.

0

There are 0 answers