Good evening. The following is an SQL-based version of the Search and Log script.
Here the search is done with the '.Global' parameter turned to false, and so the SQL also takes care of finding the number of instances per file. The logging starts after the search is done, and non-matching folders aren't listed.
SQL usage details: The script creates a temporary table called 'search_log'. My default database is the Northwind sample database, and the connection string is suited to windows authentication mode.