dbatools is a free PowerShell module with over 200 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 function is not currently available. It should be soon

Copy-SqlServerRole

Migrates server roles from one SQL Server to another. By default, all server roles are copied except default system roles. The -ServerRoles parameter is autopopulated for command-line completion and can be used to copy only specific roles.

If a role already exists on the destination, it will be skipped unless -Force is used. If -Fprce is specified, it will be dropped and recreated. No system server roles are modified.

Examples

To copy all server roles from sqlserver2014a to sqlcluster, using Windows credentials. If server roles with the same name exist on sqlcluster, they will be skipped.

To copy only two server roles, endpointadmins and replicationadmins from sqlserver2014a to sqlcluster, using SQL credentials for sqlserver2014a and Windows credentials for sqlcluster. If a server role with the same name exists on sqlcluster, it will be dropped and recreated because -Force was used.

To see what would happen if the command were executed. No actions are taken.

Get-Help

From PowerShell, execute Get-Help Copy-SqlServerRole -Detailed for more information on this function.

Source Code

Want to see the source code? View Copy-SqlServerRole.ps1 on GitHub
 

Related commands