commands

^

Repair-DbaInstanceName

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

 

Want to see the source code for this command? Check out Repair-DbaInstanceName on GitHub.
Want to see the Bill Of Health for this command? Check out Repair-DbaInstanceName.

Synopsis

Renames @@SERVERNAME to match with the Windows name.

Description

When a SQL Server's host OS is renamed, the SQL Server should be as well. This helps with Availability Groups and Kerberos.

This command renames @@SERVERNAME to match with the Windows name. The new name is automatically determined. It does not matter if you use an alias to connect to the SQL instance.

If the automatically determined new name matches the old name, the command will not run.

https://www.mssqltips.com/sqlservertip/2525/steps-to-change-the-server-name-for-a-sql-server-machine/

Syntax

Repair-DbaInstanceName
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-AutoFix]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Repair-DbaInstanceName -SqlInstance sql2014

Checks to see if the server name is updatable and changes the name with a number of prompts.

Example: 2
PS C:\> Repair-DbaInstanceName -SqlInstance sql2014 -AutoFix

Checks to see if the server name is updatable and automatically performs the change. Replication or mirroring will be broken if necessary.

Example: 3
PS C:\> Repair-DbaInstanceName -SqlInstance sql2014 -AutoFix -Force

Checks to see if the server name is updatable and automatically performs the change, bypassing most prompts and confirmations. Replication or mirroring will be broken if necessary.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

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

If this switch is enabled, the repair will be performed automatically.

Alias
Required False
Pipeline false
Default Value False
-Force

If this switch is enabled, most confirmation prompts will be skipped.

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

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value