Skip to content

Instantly share code, notes, and snippets.

@thefamousbrian
Last active February 7, 2020 15:46
Show Gist options
  • Save thefamousbrian/0f4794b48f466cdbe09ec7b7525006fa to your computer and use it in GitHub Desktop.
Save thefamousbrian/0f4794b48f466cdbe09ec7b7525006fa to your computer and use it in GitHub Desktop.
DSC Script resource to create a new failover cluster
Script NewCluster {
TestScript = {
$computerObject = Get-CimInstance -ClassName Win32_ComputerSystem
$cluster = Get-Cluster -Name $Using:clustername -Domain $computerObject.Domain
if($cluster) {
return $true
} else {
return $false
}
}
GetScript = { }
SetScript = {
$staticIPs = New-Object System.Collections.Specialized.StringCollection
$staticIPs.Add($ECRM_SQL01_CLUSTER_IP)
$staticIPs.Add($ECRM_SQL02_CLUSTER_IP)
$clusterNodes = New-Object System.Collections.Specialized.StringCollection
$clusterNodes.Add($ECRM_SQL01_HOSTNAME)
$clusterNodes.Add($ECRM_SQL02_HOSTNAME)
New-Cluster -Name CRMEXAMPLE -Node $clusterNodes -StaticAddress $staticIPs -NoStorage -Force
}
PsDscRunAsCredential = $crmAdminCred
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment