Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 444
tkrn Avatar asked Jun 06 '13 13:06

tkrn


2 Answers

As Shay Levy already explained, OwnerNode is not a string and has thus not a method ToUpper(). You can call ToUpper() on its Name property, though:

$($Group.OwnerNode.Name.ToUpper())
like image 145
Ansgar Wiechers Avatar answered Sep 28 '22 05:09

Ansgar Wiechers


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

$($Group.OwnerNode.ToString().ToUpper())
like image 28
Shay Levy Avatar answered Sep 28 '22 04:09

Shay Levy