From WikiWiki
Jump to navigation Jump to search

Find SQL servers with powershell


browser agent must be running

getting access to

Add .\administrators to sql administrators

sqlcmd -Q "if not exists(select * from sys.server_principals where name='BUILTIN\administrators') CREATE LOGIN [BUILTIN\administrators] FROM WINDOWS;EXEC master..sp_addsrvrolemember @loginame = N'BUILTIN\administrators', @rolename = N'sysadmin'" –S ComputerName\InstanceName

or run in single user mode

sqlservr -m

or run management studio as system using psexec

PsExec -s -i "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe"