dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Test-DbaServerName

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 thus, if a rename is required. It then checks conditions that would prevent a rename like database mirroring and replication.

Screenshots

test-dbaservername

Examples

To return ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a.

Test-DbaServerName -SqlServer sqlserver2014a

To return ServerInstanceName, SqlServerName, IsEqual and RenameRequired for sqlserver2014a and sql2016.

Test-DbaServerName -SqlServer sqlserver2014a, sql2016

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

Test-DbaServerName -SqlServer sqlserver2014a, sql2016 -Detailed

References

Steps to change the server name for a SQL Server machine – Jugal Shah, mssqltips.com

Get-Help

From PowerShell, execute Get-Help Test-DbaServerName -Detailed for more information on this function.

Source Code

Want to see the source code? View Test-DbaServerName.ps1 on GitHub
 

Related commands