Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Add-DbaRegServer on GitHub.
Want to see the Bill Of Health for this command? Check out Add-DbaRegServer.
Registers SQL Server instances to Central Management Server or Local Server Groups in SSMS
Registers SQL Server instances as managed servers within SSMS, either to a Central Management Server (CMS) for enterprise-wide management or to Local Server Groups for personal organization. This allows DBAs to centrally organize and quickly connect to multiple SQL Server instances from SSMS without manually typing connection details each time. The function automatically creates server groups if they don't exist and supports various authentication methods including SQL Server, Windows, and Azure Active Directory. For importing existing registered servers from other sources, use Import-DbaRegServer instead.
Add-DbaRegServer
[[-SqlInstance] <DbaInstanceParameter[]>]
[[-SqlCredential] <PSCredential>]
[[-ServerName] <String>]
[[-Name] <String>]
[[-Description] <String>]
[[-Group] <Object>]
[[-ActiveDirectoryTenant] <String>]
[[-ActiveDirectoryUserId] <String>]
[[-ConnectionString] <String>]
[[-OtherParams] <String>]
[[-InputObject] <ServerGroup[]>]
[[-ServerObject] <Server[]>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Add-DbaRegServer -SqlInstance sql2008 -ServerName sql01
Creates a registered server on sql2008's CMS which points to the SQL Server, sql01. When scrolling in CMS, the name "sql01" will be visible.
PS C:\> Add-DbaRegServer -ServerName sql01
Creates a registered server in Local Server Groups which points to the SQL Server, sql01. When scrolling in Registered Servers, the name "sql01" will be visible.
PS C:\> Add-DbaRegServer -SqlInstance sql2008 -ServerName sql01 -Name "The 2008 Clustered Instance" -Description "HR's Dedicated SharePoint instance"
Creates a registered server on sql2008's CMS which points to the SQL Server, sql01. When scrolling in CMS, "The 2008 Clustered Instance" will be visible.
Clearly this is hard to explain ;)
PS C:\> Add-DbaRegServer -SqlInstance sql2008 -ServerName sql01 -Group hr\Seattle
Creates a registered server on sql2008's CMS which points to the SQL Server, sql01. When scrolling in CMS, the name "sql01" will be visible within the Seattle group which is in the hr group.
PS C:\> Connect-DbaInstance -SqlInstance dockersql1 -SqlCredential sqladmin | Add-DbaRegServer -ServerName mydockerjam
Creates a registered server called "mydockerjam" in Local Server Groups that uses SQL authentication and points to the server dockersql1.
The target SQL Server instance if a CMS is used
Alias | |
Required | False |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the actual SQL Server instance name or network address that will be used to connect to the server.
This is the technical identifier that SSMS uses for the physical connection (e.g., "sql01.domain.com,1433" or "sql01\INSTANCE").
Alias | |
Required | False |
Pipeline | false |
Default Value |
Sets the display name that appears in the SSMS Registered Servers tree or CMS interface.
Use this to give servers meaningful, recognizable names like "Production HR Database" instead of cryptic server names. Defaults to ServerName if not specified.
Alias | |
Required | False |
Pipeline | false |
Default Value | $ServerName |
Provides additional details about the registered server that appear in SSMS properties.
Use this to document the server's purpose, environment, or important notes like "Primary OLTP for HR applications" or "Read-only replica for reporting".
Alias | |
Required | False |
Pipeline | false |
Default Value |
Places the registered server into a specific organizational folder within CMS or Local Server Groups.
Creates nested groups using backslash notation like "Production\OLTP" or "Dev\Testing". The group structure will be created automatically if it doesn't exist.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Specifies the Azure Active Directory tenant ID when registering servers that use Azure AD authentication.
Required when connecting to Azure SQL Database or SQL Managed Instance with AAD credentials.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Sets the Azure Active Directory user principal name for AAD authentication scenarios.
Use this when you want the registered server to authenticate with a specific AAD account instead of integrated authentication.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Provides a complete SQL Server connection string with all authentication and connection parameters.
Use this when you need specific connection properties like encryption settings, timeout values, or custom authentication methods not covered by other parameters.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Appends additional connection string parameters to the base connection.
Useful for adding specific connection properties like "MultipleActiveResultSets=True" or "TrustServerCertificate=True" without rebuilding the entire connection string.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Accepts a server group object from Get-DbaRegServerGroup to specify where the server should be registered.
Use this when you want to programmatically target a specific group or when piping group objects from other dbatools commands.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
Accepts an existing SMO Server object from Connect-DbaInstance to register that connection.
This preserves all connection settings and authentication from the original connection, making it ideal for registering servers you've already successfully connected to.
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the command were to run. No actions are actually performed.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |