Migrating to a new (upgraded) SQL server
I would use Copy-DbaLogin from the dbatools powershell module.
This command migrates the logins from server A to server B.
From their website the example:
Copy-DbaLogin -Source sqlserver2014a -Destination sqlcluster -Force

Copies the logins from sqlserver2014a to sqlcluster
and  overwrites them if they exist by using the -Force parameter
What does it migrate?

Migrates logins with SIDs, passwords, defaultdb, server roles &amp;
securables, database permissions &amp; securables, login attributes
(enforce password policy, expiration, etc.)

Same source as the one mentioned above