Quantcast
Channel: High Availability (Clustering) forum
Viewing all articles
Browse latest Browse all 6672

Is it possible to set the private properties of a resource using Powershell and WMI on a Windows 2003/8 cluster?

$
0
0

I'm not sure if this is the correct forum for this but I figured I would start here.

I have been trying to set the private properties of a custom cluster resource using a Powershell script on a Windows 2008 cluster, but I have been running into problems. Has anyone tried to do this? I can create a MSCluster_Resource object and update the properties that are listed under the class (PersistentState, State, etc) but when I try to set a private property using this object the changes are not saved. 

However, if I create a new privateproperties object I can make changes to the private properties, but there is no Put() method so I cannot save any changes that I make. Here is the code I have written which hopefully will make a little more sense. In this example I have an IP address resource called IP.

First I create an object for the IP address resource:

$IP = Get-WmiObject -Class MSCluster_Resource -namespace "root\MSCluster" | where { $_.Name -eq "IP" }

Next I try to set a private property for the resource using the IP object:

$IP.PrivateProperties.Address = "172.31.152.159"

Powershell accepts this command and does not throw any errors but the changes are not saved either. If I create an object that references the private properties of the resource then the changes are retained.

$IPProperties = $IP.PrivateProperties

$IPProperties.Address = "172.31.152.159"

However as soon as the object is destroyed the changes are gone, because WMI requires a Put() method to save the changes. If I try to save the changes using the $IPProperties object, I get an error stating the method does not exist.

Method invocation failed because [System.Management.ManagementBaseObject#\MSCluster_Property_Resource_IP_Address] doesn

't contain a method named 'Put'.

At line:1 char:18

+ $IPProperties.Put <<<< ()

    + CategoryInfo          : InvalidOperation: (Put:String) [], RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

The $IP resource which is a MSCluster_Resource object does contain a put method and if I change a property of the $IP object (such as PersistentState) the changes are retained. I used the following commands to do this:

$IP.PersistentState = $True

IP.Put()

Has anyone tried to modify the private properties of a resource using WMI? This is easy to do on a Windows 2008 R2 cluster, because the cluster commandlets will allow you to set private properties of a resource. Unfortunately, they only work on R2 so I am forced to use WMI to do this via a script. I can use the cluster.exe command line in my powershell scripts but I'd like to use a WMI object since it will leverage Powershell's error checking and error handling. 

Any help would be greatly appreciated.

Thanks,

Peter Roberson

SQA Engineer 

Double-Take Software


Viewing all articles
Browse latest Browse all 6672

Trending Articles



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