Is this what you're looking for?
http://sqlserverplanet.com/security/add-users-to-database-script/
(don't know if it works properly, I just did a quick google search)
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP