Indexing Service Scripts
Adding an Indexing Service CatalogAdding an Indexing Service Scope
Configuring the Indexing Service to Autostart
Enumerating Indexing Service Catalogs
Enumerating Indexing Service Scopes
Identifying the Indexing Service State
Pausing the Indexing Service
Querying the Indexing Service for File Names
Removing an Indexing Service Catalog
Removing an Indexing Service Scope
Resuming the Indexing Service
Searching by Using the Indexing Service
Starting the Indexing Service
Stopping the Indexing Service
Using a Free Text Search with the Indexing Service
Using a Predefined Indexing Service Query
Adding an Indexing Service Catalog
Adds an Indexing Service catalog named Script Catalog (with a catalog location of C:\Scripts) to the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Stop() Set objCatalog = objAdminIS.AddCatalog("Script Catalog","c:\scripts") objAdminIS.Start()
Adding an Indexing Service Scope
Adds a scope named Script Scope (with the path C:\Scripts) to an Indexing Service catalog named Script Catalog on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") Set objCatalog = objAdminIS.GetCatalogByName("Script Catalog") Set objScope = objCatalog.AddScope("c:\scripts\Indexing Server", False) objScope.Alias = "Script scope" objScope.Path = "c:\scripts"
Configuring the Indexing Service to Autostart
Configures the Indexing Service on the local computer to automatically start each time the computer starts. To configure the Indexing Service for manual start, set the parameter passed to the EnableCI method to False rather than True. Manual start is the default setting for the Indexing Service.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.EnableCI(True)
Enumerating Indexing Service Catalogs
Returns information about all the Indexing Service catalogs available on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objCatalog = objAdminIS.FindFirstCatalog() If (objCatalog) Then Set objCatAdm = objAdminIS.GetCatalog() Wscript.Echo "Catalog location: " & objCatAdm.CatalogLocation Wscript.Echo "Catalog name: " & objCatAdm.CatalogName If (objAdminIS.IsRunning) Then Wscript.Echo "Is stopped: " & objCatAdm.IsCatalogStopped Wscript.Echo "Is paused: " & objCatAdm.IsCatalogPaused Wscript.Echo "Is running: " & objCatAdm.IsCatalogRunning Wscript.Echo "Delayed filter count: " & objCatAdm.DelayedFilterCount Wscript.Echo "Documents to filter: " & objCatAdm.DocumentsToFilter Wscript.Echo "Filtered document count: " & objCatAdm.FilteredDocumentCount Wscript.Echo "Fresh test count: " & objCatAdm.FreshTestCount Wscript.Echo "Index size: " & objCatAdm.IndexSize Wscript.Echo "Percent merge complete: " & objCatAdm.PctMergeComplete Wscript.Echo "Pending scan count: " & objCatAdm.PendingScanCount Wscript.Echo "Persistent index count: " & objCatAdm.PersistentIndexCount Wscript.Echo "Query count: " & objCatAdm.QueryCount Wscript.Echo "State info: " & objCatAdm.StateInfo Wscript.Echo "Total document count: " & objCatAdm.TotalDocumentCount Wscript.Echo "Unique key count: " & objCatAdm.UniqueKeyCount Wscript.Echo "Word list count: " & objCatAdm.WordListCount End If End If Do objCatalog = objAdminIS.FindNextCatalog() If (objCatalog) Then Set objCatAdm = objAdminIS.GetCatalog() Wscript.Echo "Catalog location: " & objCatAdm.CatalogLocation Wscript.Echo "Catalog name: " & objCatAdm.CatalogName If (objAdminIS.IsRunning) Then Wscript.Echo "Is stopped: " & objCatAdm.IsCatalogStopped Wscript.Echo "Is paused: " & objCatAdm.IsCatalogPaused Wscript.Echo "Is running: " & objCatAdm.IsCatalogRunning Wscript.Echo "Delayed filter count: " & objCatAdm.DelayedFilterCount Wscript.Echo "Documents to filter: " & objCatAdm.DocumentsToFilter Wscript.Echo "Filtered document count: " & objCatAdm.FilteredDocumentCount Wscript.Echo "Fresh test count: " & objCatAdm.FreshTestCount Wscript.Echo "Index size: " & objCatAdm.IndexSize Wscript.Echo "Percent merge complete: " & objCatAdm.PctMergeComplete Wscript.Echo "Pending scan count: " & objCatAdm.PendingScanCount Wscript.Echo "Persistent index count: " & objCatAdm.PersistentIndexCount Wscript.Echo "Query count: " & objCatAdm.QueryCount Wscript.Echo "State info: " & objCatAdm.StateInfo Wscript.Echo "Total document count: " & objCatAdm.TotalDocumentCount Wscript.Echo "Unique key count: " & objCatAdm.UniqueKeyCount Wscript.Echo "Word list count: " & objCatAdm.WordListCount End If Else Exit Do End If Loop
Enumerating Indexing Service Scopes
Returns information about all the Indexing Service scopes found on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objCatalog = objAdminIS.FindFirstCatalog() If (objCatalog) Then Set objCatAdm = objAdminIS.GetCatalog() Set objScopeAdm = objCatAdm.GetScope() Wscript.Echo "Alias: " & objScopeAdm.Alias Wscript.Echo "Exclude scope: " & objScopeAdm.ExcludeScope Wscript.Echo "Logon: " & objScopeAdm.Logon Wscript.Echo "Path: " & objScopeAdm.Path Wscript.Echo "Virtual scope: " & objScopeAdm.VirtualScope End If Do objCatalog = objAdminIS.FindNextCatalog() If (objCatalog) Then Set objCatAdm = objAdminIS.GetCatalog() Set objScopeAdm = objCatAdm.GetScope() Wscript.Echo "Alias: " & objScopeAdm.Alias Wscript.Echo "Exclude scope: " & objScopeAdm.ExcludeScope Wscript.Echo "Logon: " & objScopeAdm.Logon Wscript.Echo "Path: " & objScopeAdm.Path Wscript.Echo "Virtual scope: " & objScopeAdm.VirtualScope Else Exit Do End If Loop
Identifying the Indexing Service State
Returns information about the current state of the Indexing Service on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") Wscript.Echo "Is running: " & objAdminIS.IsRunning Wscript.Echo "Is paused: " & objAdminIS.IsPaused Wscript.Echo "Computer name: " & objAdminIS.MachineName
Pausing the Indexing Service
Pauses the Indexing Service on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Pause()
Querying the Indexing Service for File Names
Returns a list of all the files included in the Indexing Service catalog named Script Catalog. This script is designed to run on the local computer.
On Error Resume Next Set objConnection = CreateObject("ADODB.Connection") objConnection.ConnectionString = "provider=msidxs;" objConnection.Properties("Data Source") = "Script Catalog" objConnection.Open Set objCommand = CreateObject("ADODB.Command") strQuery = "Select Filename from Scope()" Set objRecordSet = objConnection.Execute(strQuery) Do While Not objRecordSet.EOF Wscript.Echo objRecordSet("Filename") objRecordSet.MoveNext Loop
Removing an Indexing Service Catalog
Removes an Indexing Service catalog named Script Catalog from the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Stop() errResult = objAdminIS.RemoveCatalog("Script Catalog", True) objAdminIS.Start()
Removing an Indexing Service Scope
Removes the Indexing Service scope C:\Scripts from the Indexing Service catalog named Script Catalog. This script is designed to run on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") Set objCatalog = objAdminIS.GetCatalogByName("Script Catalog") objCatalog.RemoveScope("c:\scripts")
Resuming the Indexing Service
Resumes the Indexing Service on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Continue()
Searching by Using the Indexing Service
Returns the file name and file size for all files recorded in the Script Catalog Indexing Service catalog that contain the term Win32_NetworkAdapterConfiguration.
On Error Resume Next Set objConnection = CreateObject("ADODB.Connection") objConnection.ConnectionString = "provider=msidxs;" objConnection.Properties("Data Source") = "Script Catalog" objConnection.Open Set objCommand = CreateObject("ADODB.Command") strQuery = "Select Filename, Size, Contents from Scope() Where " _ & "Contains('Win32_NetworkAdapterConfiguration')" Set objRecordSet = objConnection.Execute(strQuery) Do While Not objRecordSet.EOF Wscript.Echo objRecordSet("Filename"), objRecordSet("Size") objRecordSet.MoveNext Loop
Starting the Indexing Service
Starts the Indexing Service on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Start()
Stopping the Indexing Service
Stops the Indexing Service on the local computer.
On Error Resume Next Set objAdminIS = CreateObject("Microsoft.ISAdm") objAdminIS.Stop()
Using a Free Text Search with the Indexing Service
Uses a free text search to return the file name and file size for all files in the Indexing Service catalog Script Catalog that include the term Win32_NetworkAdapterConfiguration.
On Error Resume Next Set objConnection = CreateObject("ADODB.Connection") objConnection.ConnectionString = "provider=msidxs;" objConnection.Properties("Data Source") = "Script Catalog" objConnection.Open Set objCommand = CreateObject("ADODB.Command") strQuery = "Select Filename, Size, Contents from Scope() Where " _ & "Freetext('Win32_NetworkAdapterConfiguration')" Set objRecordSet = objConnection.Execute(strQuery) Do While Not objRecordSet.EOF Wscript.Echo objRecordSet("Filename"), objRecordSet("Size") objRecordSet.MoveNext Loop
Using a Predefined Indexing Service Query
Uses the predefined query #AllProps to return the file name, file size, and author of all the files included in the Indexing Service catalog Script Catalog on the local computer.
On Error Resume Next Set objConnection = CreateObject("ADODB.Connection") objConnection.ConnectionString = "provider=msidxs;" objConnection.Properties("Data Source") = "Script Catalog" objConnection.Open Set objCommand = CreateObject("ADODB.Command") strQuery = "Create View #AllProps as Select * from Scope()" Set objRecordSet = objConnection.Execute("Select * from Extended_FileInfo") Do While Not objRecordSet.EOF Wscript.Echo objRecordSet("Filename") & ", " & objRecordSet("Size") & _ ", " & objRecordSet("DocAuthor") objRecordSet.MoveNext Loop