Here’s a link to a quick script from Max Trinidad to list SQL Users with the SysAdmin role.
Here’s a quick way to start getting a list of SQL Server users having “SysAdmin” Role. Basically, I’m using SQLPS module (now available with SQL Server 2012) which loads all the SMO needed to help you script against your SQL engine.
This script does the following:
- Import the SQLPS Module.
- Connect to a SQL Server Instance.
- Get the SQL Logins information.
- Search for SQL users with “SysAdmin” Role, and builds a customized information in a PSObject.
- Export the information to a CSV file.
- Open the CSV file, which by default could open an Excel application(if installed on machine).