Thor Logo dbatools

Move-DbaRegServer

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

Synopsis

Moves registered servers between groups within SQL Server Central Management Server (CMS)

Description

Moves registered server entries from one group to another within Central Management Server hierarchy. This helps reorganize CMS structure when server roles change or you need to restructure your server groupings for better management. The function updates the CMS database to reflect the new group membership while preserving all server connection details and properties.

Syntax

Move-DbaRegServer
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Name] <String[]>]
    [[-ServerName] <String[]>]
    [[-Group] <String>]
    [[-InputObject] <RegisteredServer[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Move-DbaRegServer -SqlInstance sql2012 -Name 'Web SQL Cluster' -Group HR\Prod

Moves the registered server on sql2012 titled ‘Web SQL Cluster’ to the Prod group within the HR group

Example: 2
PS C:\> Get-DbaRegServer -SqlInstance sql2017 -Name 'Web SQL Cluster' | Move-DbaRegServer -Group Web

Moves the registered server ‘Web SQL Cluster’ on sql2017 to the Web group, also on sql2017

Optional Parameters

-SqlInstance

The target SQL Server instance or instances.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Name

Specifies one or more registered servers to move by their display name as shown in SSMS CMS interface. This is the friendly name you see in the registered servers tree, which may differ from the
actual server instance name.
Use this when you know the descriptive name assigned to servers in CMS but not necessarily their technical instance names.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-ServerName

Specifies one or more registered servers to move by their actual SQL Server instance name. This is the technical server\instance connection string used to connect to SQL Server.
Use this when you need to target servers by their network instance names rather than their CMS display names.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-Group

Specifies the destination group where the registered servers will be moved. Use backslash notation for nested groups like ‘Production\WebServers’.
If not specified, servers are moved to the root level of the CMS hierarchy. The target group must already exist in CMS.

PropertyValue
AliasNewGroup
RequiredFalse
Pipelinefalse
Default Value
-InputObject

Accepts registered server objects from the pipeline, typically from Get-DbaRegServer output. This allows you to filter servers first and then move the results.
Use this approach when you need complex filtering or when working with servers from multiple CMS instances.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value