Programmatically Getting Sql Cluster Virtual Name
I have written a Windows service to collect information from all of our SQL servers. The service gets installed onto each server, and utilizing WMI and SMO, inserts relevant syste
Solution 1:
With this code:
using System.Management;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MSCluster", "SELECT * FROM MSCluster_Resource");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("Name: {0}", queryObj["Name"]);
}
I can see my SQL Cluster Name (2008CLUSTERSQL) as two of the outputs:
Name: SQL IP Address i (2008CLUSTERSQL)
Name: SQL Network Name (2008CLUSTERSQL)
Will this help? I guess you can extract the name of out it?
I got this code from WMI Code Creator (http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=en), a very useful tool to browse different WMI namespaces/classes/properties.
Solution 2:
Could you use a WMI query with the mscluster WMI classes?
http://technet.microsoft.com/en-us/library/cc780572(WS.10).aspxhttp://blogs.msdn.com/clustering/archive/2008/01/08/7024031.aspx
By query I mean interrogate all the cluster's resources/groups to locate the SQL Server network name.
Post a Comment for "Programmatically Getting Sql Cluster Virtual Name"