由于我们甚至在微软的帮助下都没有找到解决我们不断增长的Windows搜索数据库的方法,因此我们决定在其达到特定限制时通过SCOM定期重建数据库。这涉及到Windows Server 2012 R2。
因此,我需要一个PowerShell脚本,调用Reset或Reindex方法,这些方法属于ISearchCatalogManager接口。
到目前为止,我想到了以下内容:
# 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()
然而,这会抛出以下异常:
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
我在这里做错了什么?
CSearchManagerClass
(请注意前面的 C),但如果我调用GetCatalog()
,则不包含方法Reindex()
或Rebuild()
。 - Matthias Güntert