Hi and thanks for taking the time to post your script. It appears a space is missing before the 'FOR LOGIN' in the dynamic sql below:
SELECT @sql = 'USE '+ '[' + @DatabaseName + ']' +'; '+ 'CREATE USER ' + @User + 'FOR LOGIN ' + @User + '; EXEC sp_addrolemember N''db_datareader'', ' + @User + '';
Again, many thanks, and like that you factored in system and logshipped db's.
Take care,
Tom