Reset SQL Server SA Login via Powershell

The Problem

You have lost or forgotten the SA password for you SQL Server box!!

The solution

This is really easy to fix.
On the server do the following:

  1. Launch Powershell as an administrator
  2. Run:
    Install-Module dbatools
  3. Answer “Y” when prompted (twice for me).
  4. Run
    Reset-DbaAdmin -SqlServer localhost\SQLEXPRESSS

    (or whatever your database is, a “.” will suffice for a standard default sql installation”)

  5. Answer “Y” to the prompts
  6. Enter your new sa password when prompted
  7. Wait

That should be it.
Try logging in as “sa” with your new password and you can now are good to go.

Full details of the dbatools can be found here; https://dbatools.io/functions/other/reset-dbaadmin/

1 thought on “Reset SQL Server SA Login via Powershell

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.