Grant Read access to all databases and server
--Run below script to grant read access to all databases and read access to see server state information.
IF NOT EXISTS
(
SELECT *
FROM sys.server_principals
WHERE name LIKE 'domain\SCOMAccount'
)
BEGIN
CREATE LOGIN [domain\SCOMAccount] FROM WINDOWS WITH DEFAULT_DATABASE = [master];
END;
GO
GRANT VIEW ANY DEFINITION to [domain\SCOMAccount]
GRANT VIEW SERVER STATE to [domain\SCOMAccount]
GRANT VIEW ANY DATABASE to [domain\SCOMAccount]
EXEC sp_MSforeachdb 'USE [?]; IF NOT EXISTS (SELECT * FROM ?.sys.database_principals
WHERE name LIKE ''domain\SCOMAccount'') CREATE USER [domain\SCOMAccount] FOR LOGIN [domain\SCOMAccount] WITH DEFAULT_SCHEMA=[dbo]';
GO
EXEC sp_MSforeachdb 'USE [?]; ALTER ROLE [db_datareader] ADD MEMBER [domain\SCOMAccount]';
EXEC sp_MSforeachdb 'USE [?]; EXEC sp_addrolemember N''db_datareader'', N''domain\SCOMAccount''';
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home