SQL Server Power Search - Get More Relevant Results

sp_help_revlogin Alternative


sp_help_revlogin, as I'm sure most readers will know, is a stored procedure that scripts logins on an instance of SQL Server. It is popular because, in addition to scripting Windows logins, it can script SQL logins without changing the SID or password. This is very useful for database migrations and refreshing development database copies.

It could be easier to use though. Using the mirroring terminology of principal and mirror (one of the uses of this procedure):

How can this be improved?

OK, you've probably guessed where this is leading. Look at this script:

The logic for this is very similar to sp_help_revlogin, but it connects to both servers and does a hell of a lot more.

Most of my clients are still using PowerShell 1.0, so that's what I've used. This should work without modification in v2.0.

Copy this into a text file, and save as "ScriptLoginDiffs.ps1".
From within PowerShell, run the script as follows:

The output is displayed to the console, but can be redirected to a file as follows:

I doubt if I will need to use sp_help_revlogin again.