I needed to run a few utilities following a site migration from SP2007 to SP2010, so naturally I wrote a script to string together all the operations, beginning with Mount-SPContentDatabase.
One or two of those utilities - console apps I've written - worked as expected when run independently. But when run inside the script, they inconsistently reported little or no work for them to do (i.e. when run independently, one would report 18 pages needing updating, but within the script, it would sometimes report only two pages needing updates, and other times even zero pages).
After a couple of days' head-scratching, I ran a SQL Trace to find out what was happening.
It turns out that some of the database tables - notably dbo.AllWebParts - are NOT populated by Mount-SPContentDatabase: they're actually populated by the first ensuing incremental crawl. Of course, it's harder to detect when that incremental crawl is finished.
Has anyone else here seen this, or even better, found a way to programmatically detect when an incremental crawl finishes?
Josh