Listing logins, users, and database mappings

This recipe lists logins and their corresponding usernames through database mappings.

Getting ready

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:

Getting ready

How to do it...

To list logins, users, and database mappings, let's use the following steps:

  1. Open PowerShell ISE as an administrator.
  2. Import the SQLPS module and create a new SMO Server Object as follows: ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.