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

2

11

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?

Nita answered 6/6, 2013 at 13:33 Comment(0)
A
25

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

$($Group.OwnerNode.ToString().ToUpper())
Anchusin answered 6/6, 2013 at 13:44 Comment(0)
W
7

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())
Weymouth answered 6/6, 2013 at 14:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.