Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How to change ResourceGroup type in failover cluster, using WMI?

$
0
0

Hello,

we're trying to use WMI, via C#, to setup a failover cluster in a Windows 2012 Server. Everything goes according to plan until the moment we try to create the resource group, and then change its type to "Generic Service".

Here's the piece of code:

ManagementBaseObject inParamsCreate = mgmtClass.GetMethodParameters("CreateGroup");
                inParamsCreate["GroupName"] = groupName;
                mgmtClass.InvokeMethod("CreateGroup", inParamsCreate, null);

ManagementClass resourceGroups = new ManagementClass(mgmtScope, new ManagementPath(@"MSCluster_ResourceGroup"), null);
resourceGroups.Get();
foreach (ManagementObject group in resourceGroups.GetInstances())
{
                    string name = group["Name"].ToString();
                    if (name.CompareTo(groupName) == 0)
                    {
                        ManagementBaseObject inParamsSet = group.GetMethodParameters("SetGroupType");

                        
                        inParamsSet["GroupType"] = (UInt32)108;
                        group.InvokeMethod("SetGroupType", inParamsSet, null);

                     }
}

The problem is, when I invoke the "SetGroupType" method, it gives a "Generic Failure" error which I can't quite decipher.

I can use "GetGroupType", which returns 9999.

Any ideas? Any feedback would be greatly appreciated.

Thank you in advance.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>