This recipe lists logins and their corresponding usernames through database mappings.
To check logins and their database mappings in SQL Server Management Studio, log in to SSMS. Go to the Security folder, expand Logins, and double-click on a particular login. This will show you the Login Properties window. Click on the User Mapping option on the left-hand pane, as shown in the following screenshot:
To list logins, users, and database mappings, let's use the following steps:
SQLPSmodule and create a new SMO Server Object as follows: ...