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.
Renaming clusters is not supported by this command because renaming clustered instances is not supported by Microsoft.
NOTE: This has only been tested in a lab environment. It was successfully tested against a number of servers (SQL2005/2014/2016 on Windows 7/2008/2012), but could still use testing, especially if mirroring is enabled. If you can test this and let us know how it works for you, we’d appreciate it.
Checks to see if the server is updatable, prompts galore, changes name.
Repair-DbaServerName -SqlServer sql2014
Even more prompts/confirms, but removes Replication or breaks mirroring if necessary.
Repair-DbaServerName -SqlServer sql2014 -AutoFix
Skips some prompts/confirms but not all of them.
Repair-DbaServerName -SqlServer sql2014 -AutoFix -Force