It have a error in script for database with -
Msg 2520, Level 16, State 5, Line 1
Could not find database 'SharePoint_AdminContent_3a1c2e'. The database either does not exist, or was dropped before a statement tried to use it. Verify if the database exists by querying the sys.databases catalog view.
Good script !