Skip to content

Instantly share code, notes, and snippets.

@gaborgsomogyi
Created February 27, 2020 18:19
Show Gist options
  • Save gaborgsomogyi/c4a9c3e351dcd6094c6a39a4aede0f1a to your computer and use it in GitHub Desktop.
Save gaborgsomogyi/c4a9c3e351dcd6094c6a39a4aede0f1a to your computer and use it in GitHub Desktop.

To read what kind of authentication method is used:

sqlcmd -S example.com -U sa -P Mssql123 -Q "EXEC xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode'"

LoginMode values:

  • 1: Windows Authentication
  • 2: SQL Server and Windows Authentication mode

To set it:

sqlcmd -S example.com -U sa -P Mssql123 -Q "EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment