Script Download:  
The script is available for download in Microsoft Script Browser for Windows PowerShell ISE. You need to install the Script Browser application first, and search for the script sample title.

This T-SQL script will demo how to find all the logins without user mapping in a specified SQL Server database. Besides, it will list all the users and logins, except for server roles and server principals with names enclosed by double hash marks “##” which are for internal system use only.

Some people may encounter an error "The login already has an account under a different user name" when creating a user account for a specified database. So they need to create a user with another login. If there are many logins, it is not easy for them to try one by one. It will be better if there is a script to find all the available logins.

image image

You can find more All-In-One Script Framework script samples at