If we are going to test that we’re in our expected configuration, we need to record what that configuration looks like. I have a hard coded list of cluster names. However, you could easily pull them from a text file, or a database. Once we have the list of clusters we can use
Get-ClusterGroupto determine the cluster roles and their current owners.
To persist this owner information I’m using
ConvertTo-Jsonand then outputting it to a file. This creates a file that can easily be read back into PowerShell as an object using
It’s also probably worth mentioning that this ideal configuration can be stored in source control. That’ll keep the file safe and you can easily keep track of any changes that are made to it.
Read on for the full set of steps.