dsccommunity / FailoverClusterDsc

This module contains DSC resources for deployment and configuration of Windows Server Failover Cluster.
MIT License
60 stars 54 forks source link

xCluster: Cluster creation fails on Server 2012 because of invalid -Force flag #188

Closed codykonior closed 6 years ago

codykonior commented 6 years ago

Details of the scenario you tried and the problem that is occurring

I'm creating a cluster on Server 2012 but the cluster creation fails with an error that -Force is an invalid argument. This is because there's a code path that uses New-Cluster -Force and that argument isn't available in Server 2012.

Verbose logs showing the problem

Suggested solution to the issue

In DSCResources\MSFT_xCluster\MSFT_xCluster.psm1 instead of setting Force = $true while building the hashtable for splatting, check whether that parameter is valid or not first.

            $newClusterParameters = @{
              Name          = $Name
              Node          = $env:COMPUTERNAME
              NoStorage     = $true
              ErrorAction   = 'Stop'
            }

            if ((Get-Command New-Cluster).Parameters["Force"]) {
                $newClusterParameters.Force = $true
            }

This allows cluster setup to complete for me.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

...
            if ($node.Role -eq "FirstClusterNode") {
                xCluster "Cluster" {
                    Name = "C1"
                    DomainAdministratorCredential = $domainAdministrator
                    StaticIPAddress = "10.0.0.21/24"
                    # If RSAT-Clustering is not installed the cluster can not be created
                    DependsOn = "[WindowsFeature]FailoverClustering", "[WindowsFeature]RSATClustering", "[Computer]Name"
                }
            } else {

The operating system the target node is running

Windows Server 2012 Standard Evaluation (no patches).

Version and build of PowerShell the target node is running

WMF 5.1

Version of the DSC module that was used ('dev' if using current dev branch)

1.10.0.0