Awesome script, I had most of these in separate scripts and now have a combined solution - thanks! 🙂
I did get one error, and fixed it by with this:
IF OBJECT_ID('tempdb..#tempdates') IS NOT NULL
BEGIN
DROP TABLE #TEMPDATES
END
I think one of the conditional checks did not create the table so wasnt able to drop it.
gsc_dba