Great script. I noticed not all of my databases were showing under --> Database(s) Details <--. The join is using name and several of my databases have logical names that don't match the actual database name.
I changed the join condition to use database_id and filtered out the extra rows by looking only for the primary file.
--> Database(s) Details <--
SELECT...
INTO #Databases_Details
FROM SYS.DATABASES D
INNER JOIN sys.master_files S
ON D.database_id= S.database_id
WHERE s.file_id = 1