classes/ClusterComputeResource.ps1

class VexaClusterComputeResource {
    [string] $Id
    [string] $Name
    [string] $EVCMode
    [string[]] $Host
    [VexaClusterDasConfig] $DasConfig = [VexaClusterDasConfig]::new()
    [VexaClusterDrsConfig] $DrsConfig = [VexaClusterDrsConfig]::new()

    VexaClusterComputeResource() {}

    VexaClusterComputeResource($View) {
        if ($View.GetType().Name -eq "ClusterComputeResource" ) {
            # Construct class using PowerCLI Get-View data
            $this.Id = $View.MoRef
            $this.Name = $View.Name
            $this.EVCMode = $View.Summary.CurrentEVCModeKey
            $this.Host = $View.Host.ForEach({$_.ToString()})
            $this.DasConfig = [VexaClusterDasConfig]::new($View.ConfigurationEx.DasConfig)
            $this.DrsConfig = [VexaClusterDrsConfig]::new($View.ConfigurationEx.DrsConfig)
        } else {
            # Reserialize object from Import-Clixml data
            $this.Id = $View.Id
            $this.Name = $View.Name
            $this.EVCMode = $View.EVCMode
            $this.Host = $View.Host.ForEach({$_.ToString()})
            $this.DasConfig = [VexaClusterDasConfig]::new($View.DasConfig)
            $this.DrsConfig = [VexaClusterDrsConfig]::new($View.DrsConfig)
        }
    }

    [array] GetArrayToCompare() {
        $Items = $this.PSObject.Properties.Where({
            ($_.MemberType -eq "Property") -and -not
            ($_.Name -in @(
                "DasConfig",
                "DrsConfig",
                "Host"
            ))
        })
        return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}})
    }
}

class VexaClusterDasConfig {
    [bool] $Enabled
    [string] $VmMonitoring
    [string] $HostMonitoring
    [string] $VmComponentProtecting
    [int] $FailoverLevel
    [bool] $AdmissionControlEnabled
    [VexaClusterAdmissionControlPolicy] $AdmissionControlPolicy = [VexaClusterAdmissionControlPolicy]::new()
    [VexaClusterDefaultVmSettings] $DefaultVmSettings = [VexaClusterDefaultVmSettings]::new()

    VexaClusterDasConfig() {}

    VexaClusterDasConfig($DasConfig) {
        $this.Enabled = $DasConfig.Enabled
        $this.VmMonitoring = $DasConfig.VmMonitoring
        $this.HostMonitoring = $DasConfig.HostMonitoring
        $this.VmComponentProtecting = $DasConfig.VmComponentProtecting
        $this.FailoverLevel = $DasConfig.FailoverLevel
        $this.AdmissionControlEnabled = $DasConfig.AdmissionControlEnabled
        $this.AdmissionControlPolicy = [VexaClusterAdmissionControlPolicy]::new($DasConfig.AdmissionControlPolicy)
        $this.DefaultVmSettings = [VexaClusterDefaultVmSettings]::new($DasConfig.DefaultVmSettings)
    }

    [array] GetArrayToCompare() {
        $Items = $this.PSObject.Properties.Where({
            ($_.MemberType -eq "Property") -and -not
            ($_.Name -in @(
                "AdmissionControlPolicy",
                "DefaultVmSettings"
            ))
        })
        return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}})
    }
}

class VexaClusterDrsConfig {
    [bool] $Enabled
    [bool] $EnableVmBehaviorOverrides
    [string] $DefaultVmBehavior
    [string] $VmotionRate

    VexaClusterDrsConfig() {}

    VexaClusterDrsConfig($DrsConfig) {
        $this.Enabled = $DrsConfig.Enabled
        $this.EnableVmBehaviorOverrides = $DrsConfig.EnableVmBehaviorOverrides
        $this.DefaultVmBehavior = $DrsConfig.DefaultVmBehavior
        $this.VmotionRate = $DrsConfig.VmotionRate
    }

    [array] GetArrayToCompare() {
        $Items = $this.PSObject.Properties.Where({$_.MemberType -eq "Property"})
        return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}})
    }
}

class VexaClusterAdmissionControlPolicy {
    [int] $CpuFailoverResourcesPercent
    [int] $MemoryFailoverResourcesPercent
    [string] $FailoverLevel
    [bool] $AutoComputePercentages
    [int] $ResourceReductionToToleratePercent

    VexaClusterAdmissionControlPolicy() {}

    VexaClusterAdmissionControlPolicy($AdmissionControlPolicy) {
        $this.CpuFailoverResourcesPercent = $AdmissionControlPolicy.CpuFailoverResourcesPercent
        $this.MemoryFailoverResourcesPercent = $AdmissionControlPolicy.MemoryFailoverResourcesPercent
        $this.FailoverLevel = $AdmissionControlPolicy.FailoverLevel
        $this.AutoComputePercentages = $AdmissionControlPolicy.AutoComputePercentages
        $this.ResourceReductionToToleratePercent = $AdmissionControlPolicy.ResourceReductionToToleratePercent
    }

    [array] GetArrayToCompare() {
        $Items = $this.PSObject.Properties.Where({$_.MemberType -eq "Property"})
        return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}})
    }
}

class VexaClusterDefaultVmSettings {
    [string] $RestartPriority
    [int] $RestartPriorityTimeout
    [string] $IsolationResponse

    VexaClusterDefaultVmSettings() {}

    VexaClusterDefaultVmSettings($DefaultVmSettings) {
        $this.RestartPriority = $DefaultVmSettings.RestartPriority
        $this.RestartPriorityTimeout = $DefaultVmSettings.RestartPriorityTimeout
        $this.IsolationResponse = $DefaultVmSettings.IsolationResponse
    }

    [array] GetArrayToCompare() {
        $Items = $this.PSObject.Properties.Where({$_.MemberType -eq "Property"})
        return $Items.ForEach({@{Name = $_.Name; Value = $_.Value}})
    }
}