Copy SQL Logins and Permissions From One Server to Another
I created a series of stored procedures that accomplished a similar goal (with some powershell for flavor) based on this article Claire-Hsu - SQL Logins

I don't have a blog of my own (I know, I know) so I can't share my precise solution with you.  I essentially created three stored procedures.  One for the server logins, one for database and another for database object permissions.

Ah, shared on my one drive.  Link to files  It's the stored procedures you need.  I have them in my DBA database.  I then use Powershell to get a list of logins, then query the stored procedure, save the script to a file and repeat.  You could easily change it to run the script on a different server.