DBA- Generate Script To Bring All User Databases Online in SQL Server

The below query can be used to generate scripts to bring SQL Server Databases from Offline state to Online.

SELECT 'ALTER DATABASE ['+name+'] SET ONLINE'+CHAR(10)+' GO' 
FROM MASTER.sys.databases
WHERE name NOT IN ('master','tempdb','model','msdb','distribution')
AND state_desc='OFFLINE'