Topics from the Microsoft SQL Server Protocols team - Netlibs, TDS, SQL Browser, etc.
In my previous post, I provided some sample C# code that allows you to configure SQL Server connection properties remotely through Windows Management Instrumentation. But WMI can also be used to configure client connection properties on a remote machine. Below I will provide some sample C# code to manage client side Aliases.
Alias is a client side feature which enables you to use an alternative name to make a connection. For example, if you don't want to use explicit server name in your application or you don't wish to use SqlBrowser service for discovery, you may create server aliases. For this reason, a lot of IT professionals have the need to programmatically configure aliases remotely because they want to centrally manage hundreds or thousands of deployed client machines. Through WMI, you will be able to achieve that goal.
The following is some code that enables you to enumerate, edit, and add new aliases:
Remember to add your own exception handling code. Please note that when you try to add an alias but an existing alias on that machine already has the same alias name, this name conflict will not throw an exception. Instead, that alias will take on the new property values. Also note that the alias name is case insensitive, meaning that if you first add "Alias 1" and then add "alias 1", only 1 alias will be added and the latter alias name will be displayed as its name.
For this remote WMI script to work, the client machine does not have to have SQL Server installed, you only need to install SNAC and SQL client components. Both of these them are on your SQL Server media or package. Additionally, the firewall on the client machines must allow remote administration.
I'm trying to navigate the wasteland of documentation surrounding SMO and WMI - there is either too much about similar topics or none about others. I'm looking to not only enable Tcp/Ip in the SQLExpress protocols, but also set the IP1, IP2 and IPAll properties associated with Tcp/Ip - How do you suggest doing this? I modified the prior examples to point to SQLExpress and get what appears to be success - but the management objects dont provide the clearest view for me to learn the object model simply by reading the members and/or traversing the properties...