As we didn't find any solution to our ever growing Windows Search DBs (not even with Microsofts help) we decided to rebuild the DBs regularily by SCOM, when they hit a specific limit. This relates to Windows Server 2012 R2.
I therefor need a PowerShell script that calls the Reset or Reindex method belonging to the ISearchCatalogManager interface.
So far I came up with the following:
# Load DLL containing classes & interfaces
Add-Type -path "C:\Temp\SearchIndex\Microsoft.Search.Interop.dll"
# Create new ISearchManager object
$sm = New-Object Microsoft.Search.Interop.ISearchManager
# should return ISearchCatalogManager object
$catalog = $sm.GetCatalog("SystemIndex")
# Call the method
$catalog.Reindex()
This however throws the following exception:
New-Object : A constructor was not found. Cannot find an appropriate constructor for type Microsoft.Search.Interop.ISearchManager.
At C:\Users\myuser\Desktop\test.ps1:8 char:6
+ $sm = New-Object Microsoft.Search.Interop.ISearchManager
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : CannotFindAppropriateCtor,Microsoft.PowerShell.Commands.NewObjectCommand
What am I doing wrong here?