DSCClassResources/ClusterIp/ClusterIp.psm1

[DscResource()]
class ClusterIp {
    [DscProperty(Key)]
    [string] $ClusterResourceName

    [DscProperty(Mandatory)]
    [string]$IPv4Address

    [DscProperty(Mandatory)]
    [string]$SubnetMask

    [DscProperty(NotConfigurable)]
    [string]$ActualIpAddress

    [DscProperty(NotConfigurable)]
    [int]$EnableDhcp

    [DscProperty(NotConfigurable)]
    [string]$Network

    # Gets the resource's current state.
    [ClusterIp] Get() {
        try {
            $clusterResource = Get-ClusterResource | Where-Object {$_.Name -like $this.ClusterResourceName}
            $this.ClusterResourceName = $clusterResource.Name
        }
        catch {
            Write-Verbose "Could not find Cluster Resource with Filter: $($this.ClusterResourceName)"
            $this.ActualIpAddress = $null
            return $this
        }

        $this.Network = ($clusterResource |Get-ClusterParameter -Name "Network").Value  
        $this.ActualIpAddress = ($clusterResource |Get-ClusterParameter -Name "Address").Value
        $this.EnableDhcp = ($clusterResource |Get-ClusterParameter -Name "EnableDhcp").Value        
        return $this
    }

    # Sets the desired state of the resource.
    [void] Set() {
        $currentConfig = $this.Get()
        $clusterObj = Get-ClusterResource $this.ClusterResourceName
        if ($null -eq $currentConfig.ActualIpAddress) {
            throw "Could not find resource"
        }
        else {
            $clusterObj | Set-ClusterParameter -Multiple @{"Address" = $this.IPv4Address; "Network" = $this.Network; "SubnetMask" = $this.SubnetMask; "EnableDhcp" = 0}
        }
    }
    
    # Tests if the resource is in the desired state.
    [bool] Test() {
        $currentConfig = $this.Get()
        if ($currentConfig.ActualIpAddress -eq $this.IPv4Address) {
            return $true
        }
        else {
            return $false
        }
    }
}