Why can't I apply ToUpper() to an OwnerNode?

tkrn picture tkrn · Jun 6, 2013 · Viewed 49.3k times · Source

This works:

Output "Cluster Group: ""$($Group.Name)"", Current Owner: $($Group.OwnerNode), Current State: $($Group.State)"

This does not work:

Output "Cluster Group: ""$($Group.Name)"", Current Owner: $($Group.OwnerNode.ToUpper()), Current State: $($Group.State)"

With an error of this:

Method invocation failed because [Microsoft.FailoverClusters.PowerShell.ClusterNode] doesn't contain a method named 'ToUpper'.

Any ideas on how to get this to string from the output of the Get-ClusterGroup string to upper case?

Answer

Shay Levy picture Shay Levy · Jun 6, 2013

ToUpper() is a string method and OwnerNode is probably not a string. Call the ToString() method before calling ToUpper().

$($Group.OwnerNode.ToString().ToUpper())