commands

^

Add-DbaRegServer

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Adds registered servers to SQL Server Central Management Server (CMS) or Local Server Groups

Description

Adds registered servers to SQL Server Central Management Server (CMS) or Local Server Groups. If you need more flexibility, look into Import-DbaRegServer which accepts multiple kinds of input and allows you to add reg servers from different CMSes.

Syntax

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>]

 

Examples

 

Example: 1
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.

Example: 2
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.

Example: 3
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 ;)

Example: 4
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.

Example: 5
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.

Optional Parameters

-SqlInstance

The target SQL Server instance if a CMS is used

Alias
Required False
Pipeline false
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.

Alias
Required False
Pipeline false
Default Value
-ServerName

Server Name is the actual SQL instance name (labeled Server Name)

Alias
Required False
Pipeline false
Default Value
-Name

Name is basically the nickname in SSMS Registered Server interface (labeled Registered Server Name)

Alias
Required False
Pipeline false
Default Value $ServerName
-Description

Adds a description for the registered server

Alias
Required False
Pipeline false
Default Value
-Group

Adds the registered server to a specific group. If group does not exist it will be created

Alias
Required False
Pipeline false
Default Value
-ActiveDirectoryTenant

Active Directory Tenant

Alias
Required False
Pipeline false
Default Value
-ActiveDirectoryUserId

Active Directory User id

Alias
Required False
Pipeline false
Default Value
-ConnectionString

SQL Server connection string

Alias
Required False
Pipeline false
Default Value
-OtherParams

Additional parameters to append to the connection string

Alias
Required False
Pipeline false
Default Value
-InputObject

Allows the piping of a registered server group

Alias
Required False
Pipeline true (ByValue)
Default Value
-ServerObject

SMO Server Objects (from Connect-DbaInstance)

Alias
Required False
Pipeline true (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.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

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

Alias wi
Required False
Pipeline false
Default Value
-Confirm

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

Alias cf
Required False
Pipeline false
Default Value

 

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.