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


Copy-SqlCentralManagementServer

This command copies all groups, subgroups, and registered servers from one SQL Server to another. By default, all objects are copied.

The -SqlCmsGroups parameter is autopopulated for command-line completion and can be used to copy only specific groups.

If the group or registered server already exists on the destination, it will be skipped unless -Force is specified. Force drops and recreates the object.

Examples

To migrate all groups, subgroups, and server instances are copied from sqlserver’s Central Management Server to sqlcluster’s Central Management Server.

To migrate top level Group1 and Group3, along with its subgroups and server instances are copied from sqlserver to sqlcluster.

To migrate top level Group1 and Group3, along with its subgroups and server instances are copied from sqlserver to sqlcluster. When adding sql instances to sqlcluster, if the server name of the migrating instance is “sqlcluster”, it will be switched to “sqlserver”. If SwitchServerName is not specified, “sqlcluster” will be skipped.

From PowerShell, execute   Get-Help Copy-SqlCentralManagementServer -Detailed   for more information on this function. Want to see the source code? See it on GitHub