---------------- Solarwinds DPA grant access script -------------
-- Change the DOMAINNAME\User
USE master
GO
IF NOT EXISTS(SELECT * FROM sys.syslogins WHERE name = 'MED\swadmin')
BEGIN
print 'CREATE LOGIN'
CREATE LOGIN "MED\swadmin" FROM WINDOWS
END
GO
GRANT VIEW SERVER STATE TO "MED\swadmin"
GO
GRANT VIEW ANY DEFINITION TO "MED\swadmin"
GO
print 'sp_adduser'
EXEC sp_adduser @loginame = 'MED\swadmin', @name_in_db = 'MED\swadmin'
GO
GRANT EXECUTE ON xp_readerrorlog TO "MED\swadmin"
GO
USE msdb
GO
print 'sp_adduser'
EXEC sp_adduser @loginame = 'MED\swadmin', @name_in_db = 'MED\swadmin'
GO
EXEC sp_addrolemember N'db_datareader', N'MED\swadmin'
GO
print 'Loop Start'
go
EXEC sp_MSforeachdb 'USE [?]; EXEC sp_adduser @loginame = ''MED\swadmin'''
GO
|
No comments:
Post a Comment