commands

^

Test-DbaInstanceName

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

 

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

Synopsis

Tests to see if it's possible to easily rename the server at the SQL Server instance level, or if it even needs to be changed.

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 helps determine if your OS and SQL Server names match, and whether a rename is required.

It then checks conditions that would prevent a rename, such as database mirroring and replication.

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.

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

If this switch is enabled, checking for SQL Server Reporting Services 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