dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


This command syncs SQL login permissions from one server to another including login permissions, roles, database permissions and more. By default, all logins are synced. The -Logins and -Excludes parameters is autopopulated for command-line completion and can be used to sync only specific logins.

If a matching login or securable does not exist on the destination, the permission sync will be skipped.

Credential removal and application role syncs not currently supported.


To copy all database & server permission sets & securables from sqlserver to sqlcluster, using integrated (Windows) login. If logins with the same name exist do not exist on sqlcluster, they will be skipped.


To copy the permissions for only two SQL logins, netnerds and realcajun, as well as one Windows login ‘base\ctrlb’


To see what would happen if you were to execute the command. No actions are taken.



From PowerShell, execute Get-Help Sync-DbaSqlLoginPermission -Detailed for more information on this function.

Source Code

Want to see the source code? View Sync-DbaSqlLoginPermission.ps1 on GitHub

Related commands