Q about Get-CauClusterRole

65 views
Skip to first unread message

Mike Leone

unread,
Mar 21, 2024, 11:24:02 AM3/21/24
to NTPowershell Mailing List
So we have a number of Windows failover clusters, and we update them using Cluster Aware Updating. I wanted to retrieve the settings, because this month, I needed to change the date the updating occurred. So I did:

> Get-CauClusterRole -Cluster PHAMSCLUST14

Name                Value
----                -----
ResourceGroupName   CAUPHAMScvk
Status              Online
StartDate           8/1/2021 3:00:00 AM
CauPluginName       Microsoft.WindowsUpdatePlugin
CauPluginArguments  @{ 'IncludeRecommendedUpdates' = 'True' }
MaxRetriesPerNode   3
EnableFirewallRules True
FailbackMode        Immediate
DaysOfWeek          Sunday
WeeksOfMonth        4

Which is great, it tells me that the scheduled update is Sunday, on the 4th week of the month.

So I decided to try to just select the parts I'm interested in, and that's when I got confused ..

> Get-CauClusterRole -Cluster PHAMSCLUST17  | Select DaysOfWeek, WeeksOfMonth

DaysOfWeek WeeksOfMonth
---------- ------------

So apparently the output returned is in some sort of class of object that I am not referencing correctly. Google isn't helping with scripting examples, just setting via GUI.

I see examples for the Set-CauClusterRole that seem to indicate that I need to make a custom object of the parameters, and then I can pass it to the cmdlet to set those parameters. But how do you do the reverse - i.e., put all those returned parameters into something I can output easily?

I tried seeing the makeup of the object returned, and I got lost that way, too ..

> $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17
> $cau | gm


   TypeName: Microsoft.ClusterAwareUpdating.CauParameter

Name        MemberType Definition
----        ---------- ----------
Equals      Method     bool Equals(System.Object obj)
GetHashCode Method     int GetHashCode()
GetType     Method     type GetType()
ToString    Method     string ToString()
Name        Property   string Name {get;}
Value       Property   System.Object Value {get;}

Anyone got a pointer to teach me how to parse out what I need from this command?

--

Mike. Leone, <mailto:tur...@mike-leone.com>

PGP Fingerprint: 0AA8 DC47 CB63 AE3F C739 6BF9 9AB4 1EF6 5AA5 BCDF
Photo Gallery: <http://www.flickr.com/photos/mikeleonephotos>

Wright, John M

unread,
Mar 21, 2024, 12:23:15 PM3/21/24
to ntpowe...@googlegroups.com

What happens if you run this (I would check myself but we don’t use clusters):

 

(Get-CauClusterRole -Cluster PHAMSCLUST14).name.DaysOfWeek

 

--

John Wright

IT Support Specialist

1800 Old Bluegrass Avenue, Louisville, KY 40215

502.708.9953

Please submit IT requests to Hazelwoo...@bluegrass.org

24 Hour Helpline 1.800.928.8000

  

CONFIDENTIALITY NOTICE: This message contains confidential information and is intended only for the individual(s) addressed in the message. If you are not the named addressee, you should not disseminate, distribute, or copy this e-mail. If you are not the intended recipient, you are notified that disclosing, distributing, or copying this e-mail is strictly prohibited.

 

From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Mike Leone
Sent: Thursday, March 21, 2024 11:24 AM
To: NTPowershell Mailing List <ntpowe...@googlegroups.com>
Subject: [ntpowershell] Q about Get-CauClusterRole

 

This message is from an external sender.

--
You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ntpowershell/CAHBr%2B%2Bhf4ezAN9e%2BAZ-nJOWkGW6YypmQaKYE2xFD%3D6a4Nnip1Q%40mail.gmail.com.

[CAUTION] Do not click on links or open attachments unless you recognize the sender and know the content is safe.
If you believe this is a malicious email, please forward it the local IT team and click the Report Message button in Outlook.

 

Michael B. Smith

unread,
Mar 21, 2024, 1:57:15 PM3/21/24
to ntpowe...@googlegroups.com

It’s probably a hash table. But I also don’t have a cluster handy to check.

Mike Leone

unread,
Mar 21, 2024, 2:33:57 PM3/21/24
to ntpowe...@googlegroups.com
On Thu, Mar 21, 2024 at 12:23 PM Wright, John M <John....@newvista.org> wrote:

What happens if you run this (I would check myself but we don’t use clusters):

 

(Get-CauClusterRole -Cluster PHAMSCLUST14).name.DaysOfWeek


Nope.

> (Get-CauClusterRole -Cluster PHAMSCLUST17).DaysOfWeek
> (Get-CauClusterRole -Cluster PHAMSCLUST17).Name.DaysOfWeek


Mike Leone

unread,
Mar 21, 2024, 2:35:37 PM3/21/24
to ntpowe...@googlegroups.com
On Thu, Mar 21, 2024 at 1:57 PM Michael B. Smith <mic...@smithcons.com> wrote:

It’s probably a hash table. But I also don’t have a cluster handy to check.


I don't have a lot of experience with hash tables, so I guess you might be right? :-)

The examples show using splatting to set values. I just don't know how you would do the reverse (i.e., get the values into a splatt) ...

$parameters = @{ ClusterName = 'CONTOSO-FC1' DaysOfWeek = 'Tuesday' WeeksOfMonth = '1,2' RebootTimeoutMinutes = '10' Force = $true } Set-CauClusterRole $parameters



 

Michael B. Smith

unread,
Mar 21, 2024, 2:53:16 PM3/21/24
to ntpowe...@googlegroups.com

Pure guess:

 

     $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17

     $CAU[ 'DaysOfWeek' ]

Helton, Matt

unread,
Mar 21, 2024, 2:53:24 PM3/21/24
to ntpowe...@googlegroups.com

For giggles, I tried executing the splat and subsequent command. The blue information bar has the following while failing to connect to an actual cluster:


Setting properties for CAU clustered role on cluster "System.Collections.Hashtable"

 

Try the following:

 

$Parameters = @{

    ClusterName = “YourClusterName”

    DaysOfWeek = “YourDay”

    WeeksOfMonth = “YourWeeksOfMonth”

    RebootTimeoutMinutes = “YaKnowWhatToDoByNow”

    Force = $true

}

 

$Result = Set-CauClusterRole @ Parameters

 

$Result.DaysOfWeek

 

Does this give you what you need?

 

Also, I’m surprised this won’t get you the info you need…

 

( Get-CauClusterRole -Cluster PHAMSCLUST14 ).DaysOfWeek

( Get-CauClusterRole -Cluster PHAMSCLUST14 ).WeeksOfMonth

 

At the very least it should return the values for those parameters for that cluster. As with others, I don’t have clusters so I cannot test that. However, I did test it with other commands using splats.

 

Later,

Matt Helton

(he/him/his)

Assistant System Administrator

Library Information Technology Services

Milner Library, Room 177

Illinois State University

Office: 309-438-2876

Help Desk: 309-438-8399

Help E-mail: librar...@ilstu.edu

 

Sent: Thursday, March 21, 2024 13:35
To: ntpowe...@googlegroups.com
Subject: Re: [ntpowershell] Q about Get-CauClusterRole

 

This message originated from outside of the Illinois State University email system. Learn why this is important

Helton, Matt

unread,
Mar 21, 2024, 2:55:03 PM3/21/24
to ntpowe...@googlegroups.com

Formatting fail caused a space between ‘@’ and ‘Parameters’. There should be no space between those two.

 

Matt Helton

(he/him/his)

Assistant System Administrator

Library Information Technology Services

Milner Library

Illinois State University

 

From: 'Helton, Matt' via ntpowershell <ntpowe...@googlegroups.com>
Sent: Thursday, March 21, 2024 13:53
To: ntpowe...@googlegroups.com
Subject: RE: [ntpowershell] Q about Get-CauClusterRole

 

This message originated from outside of the Illinois State University email system. Learn why this is important

Mike Leone

unread,
Mar 21, 2024, 3:04:23 PM3/21/24
to ntpowe...@googlegroups.com
On Thu, Mar 21, 2024 at 2:53 PM 'Helton, Matt' via ntpowershell <ntpowe...@googlegroups.com> wrote:

For giggles, I tried executing the splat and subsequent command. The blue information bar has the following while failing to connect to an actual cluster:


Setting properties for CAU clustered role on cluster "System.Collections.Hashtable"

 

Try the following:

 

$Parameters = @{

    ClusterName = “YourClusterName”

    DaysOfWeek = “YourDay”

    WeeksOfMonth = “YourWeeksOfMonth”

    RebootTimeoutMinutes = “YaKnowWhatToDoByNow”

    Force = $true

}

 

$Result = Set-CauClusterRole @ Parameters

 

$Result.DaysOfWeek

 

Does this give you what you need?


Well, I don't have a spare cluster to try changing values to. And I don't want to use a production cluster.

I know I can set the values like this:

Set-CauClusterRole -ClusterName PHAMSCLUST14 -Force -CauPluginName Microsoft.WindowsUpdatePlugin -CauPluginArguments @{ 'IncludeRecommendedUpdates' = 'True' } -MaxRetriesPerNode 3 -StartDate "8/1/2021 3:00:00 AM" -DaysOfWeek 1 -WeeksOfMonth @(4) -UseDefault -EnableFirewallRules;Enable-CauClusterRole -ClusterName PHAMSCLUST14 -VERBOSE  -Force;

(that's how I set them to a known different value. I am just not sure how to just return values, without changing them, as above.


 

Also, I’m surprised this won’t get you the info you need…

 

( Get-CauClusterRole -Cluster PHAMSCLUST14 ).DaysOfWeek

( Get-CauClusterRole -Cluster PHAMSCLUST14 ).WeeksOfMonth

 

At the very least it should return the values for those parameters for that cluster. As with others, I don’t have clusters so I cannot test that. However, I did test it with other commands using splats.


Nope, gives me back nothing.

 > (Get-CauClusterRole -Cluster PHAMSCLUST17).DaysOfWeek
> (Get-CauClusterRole -Cluster PHAMSCLUST17).WeeksOfMonth

Set-CauClusterRole has a whole lot of options to pass values to, as above; Get-CauClusterRole does not ...


Mike Leone

unread,
Mar 21, 2024, 3:06:57 PM3/21/24
to ntpowe...@googlegroups.com
On Thu, Mar 21, 2024 at 2:53 PM Michael B. Smith <mic...@smithcons.com> wrote:

Pure guess:

 

     $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17

     $CAU[ 'DaysOfWeek' ]


Unfortunately not:
>

Michael B. Smith

unread,
Mar 21, 2024, 3:09:37 PM3/21/24
to ntpowe...@googlegroups.com

Try something just a little different from what you’ve already done and send us the output:

 

     $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17

     gm -I $CAU

This will prevent the array unrolling that I think happened in your initial posting.

Mike Leone

unread,
Mar 21, 2024, 3:14:35 PM3/21/24
to ntpowe...@googlegroups.com
On Thu, Mar 21, 2024 at 3:09 PM Michael B. Smith <mic...@smithcons.com> wrote:

Try something just a little different from what you’ve already done and send us the output:

 

     $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17
     gm -I $CAU

This will prevent the array unrolling that I think happened in your initial posting.


Huh. I didn't know "gm" had parameters ...

PS O:\software\PHA Scripts\AD related scripts> $CAU = Get-CauClusterRole -Cluster PHAMSCLUST17
PS O:\software\PHA Scripts\AD related scripts> gm -I $CAU


   TypeName: System.Object[]


Name           MemberType            Definition
----           ----------            ----------
Count          AliasProperty         Count = Length
Add            Method                int IList.Add(System.Object value)
Address        Method                System.Object&, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Address(int )
Clear          Method                void IList.Clear()
Clone          Method                System.Object Clone(), System.Object ICloneable.Clone()
CompareTo      Method                int IStructuralComparable.CompareTo(System.Object other, System.Collections.IComparer comparer)
Contains       Method                bool IList.Contains(System.Object value)
CopyTo         Method                void CopyTo(array array, int index), void CopyTo(array array, long index), void ICollection.CopyTo(array array, int index)
Equals         Method                bool Equals(System.Object obj), bool IStructuralEquatable.Equals(System.Object other, System.Collections.IEqualityComparer c...
Get            Method                System.Object Get(int )
GetEnumerator  Method                System.Collections.IEnumerator GetEnumerator(), System.Collections.IEnumerator IEnumerable.GetEnumerator()
GetHashCode    Method                int GetHashCode(), int IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
GetLength      Method                int GetLength(int dimension)
GetLongLength  Method                long GetLongLength(int dimension)
GetLowerBound  Method                int GetLowerBound(int dimension)
GetType        Method                type GetType()
GetUpperBound  Method                int GetUpperBound(int dimension)
GetValue       Method                System.Object GetValue(Params int[] indices), System.Object GetValue(int index), System.Object GetValue(int index1, int inde...
IndexOf        Method                int IList.IndexOf(System.Object value)
Initialize     Method                void Initialize()
Insert         Method                void IList.Insert(int index, System.Object value)
Remove         Method                void IList.Remove(System.Object value)
RemoveAt       Method                void IList.RemoveAt(int index)
Set            Method                void Set(int , System.Object )
SetValue       Method                void SetValue(System.Object value, int index), void SetValue(System.Object value, int index1, int index2), void SetValue(Sys...
ToString       Method                string ToString()
Item           ParameterizedProperty System.Object IList.Item(int index) {get;set;}
IsFixedSize    Property              bool IsFixedSize {get;}
IsReadOnly     Property              bool IsReadOnly {get;}
IsSynchronized Property              bool IsSynchronized {get;}
Length         Property              int Length {get;}
LongLength     Property              long LongLength {get;}
Rank           Property              int Rank {get;}
SyncRoot       Property              System.Object SyncRoot {get;}
 

Michael B. Smith

unread,
Mar 21, 2024, 3:19:03 PM3/21/24
to ntpowe...@googlegroups.com

Ok it’s just a simple array. So you have to iterate through it:

 

$CAU = Get-CauClusterRole -Cluster PHAMSCLUST17

foreach( $item in $CAU ) {

     $item.Name + ' = ' + $item.Value

}

 

Not a very efficient implementation.

Reply all
Reply to author
Forward
0 new messages