ALIASES

Quick PS script to get SQL Server Configuration Aliases

Aliases!

They can be quite helpful, but they can also be a major pain when setting up new servers or migrating to a new server.

Trust me, we just got burned by this recently. A missed alias resulted in a critical app being down for a while until we figured it out.

If you use aliases and don’t have them all setup on your new machine you can pretty much expect things to break.

It is also a pain to sit and transcribe the various alias settings to be able to rebuild them all on the next machine.

There is an export list option for the aliases on your server, that’s nice and all, but there isn’t a corresponding import option.

Plus you have to deal with 32 and 64 bit lists.

The very simple script below helps since you can use to get the details of both the 32 and 64bit SQL Server aliases you have setup on your system.

Ready for it? It’s a long convoluted one:

Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo'

That’s it?

Yeah. That’s it.

All the alias information is stored nice and neat in the registry.

This is a very simple PS script to dump the properties of the registry location of the SQL Server configuration manager alias scripts.

Heck, if you know the path to any other property in the registry you can dump that as well using the same Get-ItemProperty.

 

Now if only there was a way script to read that info in on a new server and set the registry value quickly for all the aliases you may need.

Maybe that’ll be next time…

 

[divider][icon_box icon=”users” title=”Who is Chris Bell?”]

Chris Bell, SQL Server MVP, MCSE & MCITP, is a 20 year veteran of using Microsoft products & SQL Server to create solutions for businesses, organizations and individuals. Chris speaks, blogs, writes articles and makes media of all kinds regarding SQL Server at WaterOxConsulting.com. Chris is also the founder of WaterOx Consulting, Inc. which features SQL Server consulting services, training and the FREE sp_WOxCompliant compliance check script for your SQL Server environment.

Click here to contact Chris or to follow him on twitter. [/icon_box]