How do you clone SQL permissions from one account to another using dbatools

When a new hire or existing user needs access to a database or multiple databases. Easiest way is to figure out if there is any existing user whose permissions can be cloned and applied to the new user.


The following step works if DBAUtility database is already setup and you are running SQL agent job to capture a snapshot of all user permissions across the entire SQL instance.

USE DBAUtility
EXEC perms.clonePermissions @UserName = N'Domain\user1',      -- nvarchar(256)
                            @NewUser = N'Domain\user2',       -- nvarchar(256)
                            @logintype = 'U',      -- char(1)
                            @CreateLogins = 1, -- bit
                            @ExecuteScript = 1-- bit

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: