Blog posts describing the process can be found here
http://sqldbawithabeard.com/2014/02/25/rationalisation-of-database-with-powershell-and-t-sql-part-one/[/url]
http://sqldbawithabeard.com/2014/03/03/rationalisation-of-database-with-powershell-and-t-sql-part-two-2/[/url]