Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an x64 machine that regularly needs about 10 aliases changed in the SQL Server Client Network Utility (cliconfig) for both the x64 and x86 sides of the registry. Is there a way I could do this with a powershell script?

share|improve this question
add comment

2 Answers 2

up vote 9 down vote accepted

cliconfig.exe is used in SQL Server 2000, the right tool to be using for SQL Server 2008 is SQL Server Configuration Manager. Nonetheless they both seem to manipulate the same registry keys.

For x86:

HKLM\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo

For x64:

HKLM:\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo

To create a new TCP alias with powershell (although you can use any tool that manipulates the registry) use the following:

New-ItemProperty HKLM:SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo -name alias1 -propertytype String -value "DBMSSOCN,servera,2001"

Where alias1 is the name of the alias, servera is the name of the server and 2001 is the TCP port.

share|improve this answer
    
How did you figure out what registry key was being changed by that exe? –  Sam Aug 19 '09 at 15:58
    
sysinternals tools! –  Nick Kavadias Aug 20 '09 at 16:20
add comment

I believe you should use WMI for doing this. In root\Microsoft\SqlServer\ComputerManagement namespace there is an object of type SqlServerAlias which corresponds to server alias. Try using it - as far as I know using WMI is a recommended way of performing such tasks.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.