SQL Server – Local Admins on SQL Server Systems

powershellsql server

I need to monitor the local admins on my SQL Server systems for auditing. Is there a way to use a stored procedure with powershell to accomplish that?

Best Answer

You don't need to use Powershell for this, which would require xp_cmdshell in a stored procedure. Just use xp_logininfo. As long as you add the group to SQL Server (you don't have to give it any permissions), you can query the members of it.

EXEC master.dbo.xp_logininfo 'Builtin\Administrators', 'members'