Thor Logo dbatools

Test-DbaInstanceName

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

Synopsis

Validates SQL Server instance name consistency with the host OS and identifies rename requirements and potential blockers.

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 compares the SQL Server instance name (from @@servername) with the actual hostname and instance combination to determine if they match. When they don’t match, a rename is typically required to prevent authentication issues and ensure proper cluster functionality.

The function also performs critical safety checks by scanning for conditions that would prevent a safe rename, including active database mirroring, replication configurations (publishing, subscribing, or distribution), and remote login dependencies. Additionally, it identifies SQL Server Reporting Services installations that would require manual updates after a server rename.

Use this before attempting any server rename operations to understand the scope of work involved and potential complications. The detailed output helps you plan the rename process and address blockers beforehand.

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

Syntax

Test-DbaInstanceName
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-ExcludeSsrs]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Test-DbaInstanceName -SqlInstance sqlserver2014a

Returns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a.

Example: 2
PS C:\> Test-DbaInstanceName -SqlInstance sqlserver2014a, sql2016

Returns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.

Example: 3
PS C:\> Test-DbaInstanceName -SqlInstance sqlserver2014a, sql2016 -ExcludeSsrs

Returns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016, but skips validating if SSRS is installed on both instances.

Example: 4
PS C:\> Test-DbaInstanceName -SqlInstance sqlserver2014a, sql2016 | Select-Object *

Returns ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.
If a Rename is required, it will also show Updatable, and Reasons if the server name is not updatable.

Required Parameters

-SqlInstance

The target SQL Server instance or instances.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default Value
-ExcludeSsrs

Skips checking for SQL Server Reporting Services installations that would require manual updates after a server rename.
Use this switch when you know SSRS isn’t installed or when you want to focus only on core SQL Server rename blockers.
Without this switch, the function will warn about SSRS configurations that need attention during rename operations.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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