Powershell Create Windows 2008 R2 Cluster   Leave a comment

Teched 2010 Berlin #TEE10 #Teched

For Demo and learning Sites you need often thing that takes only a minute but when you play with it it takes more time than you want.So with this in my mind I created 3 powershell scripts that you can use for building a cluster , NLB Cluster and a MSTDC cluster resource.So If you want to create a Cluster you can do this in the GUI or with a Powershell Script.

So make sure the disk are formatted and that Your network is ok. and if you running this script in a environment with a Windows 2003 DC with DNS. You may have to set extra security to get things working.

You can find the Scripts Here : Powershell Scripts

Powershell Create Cluster Teched 2010 Berlin #TEE10 #Teched

This Cluster creation script creates a two node cluster with a witness disk at your choice. First we do the import of the modules and add the feature for failover clusters this section you have to do this on every node. You can do this remote if you want. Or run the script on the other node and abort it on the input section.

 

#Importing Microsoft`s PowerShell-modules
Write-Host "Install System Modules" -ForegroundColor yellow
ImportSystemModules
#Add-WindowsFeature
Write-Host "Add Failover Clustering" -ForegroundColor yellow
Add-WindowsFeature Failover-Clustering
#Importing Microsoft`s PowerShell-module for administering NLB Clusters
Write-Host "Install ServerManager Modules" -ForegroundColor yellow
Import-Module ServerManager

Here we put the cluster names , netbios, clustername, IP etc.

#Variables for creating the new cluster
Write-Host "Cluster Properties Hostname / Node Names" -ForegroundColor yellow
$Clusternode1 = Read-Host "Enter ClusterNode 1 for the new cluster"
$Clusternode2 = Read-Host "Enter ClusterNode 2 for the new cluster"
$ClusterFqdn = Read-Host "Enter Cluster for the new cluster"
$ClusterIP = Read-Host "Enter cluster primary IP"
#Clear old Cluster info
Write-Host "Old Cluster Configuration Will Be ereased just to make sure" -ForegroundColor yellow
Clear-ClusterNode $Clusternode1 -force
Clear-ClusterNode $Clusternode2 -force

#Validating new cluster
Write-Host "Validate Windows 2008 R2 Cluster…" -ForegroundColor yellow
Test-Cluster $Clusternode1 -ignore network,inventory,storage

#Creating new cluster
Write-Host "Create Windows 2008 R2 Cluster…" -ForegroundColor yellow
New-Cluster -Node "$Clusternode1" -Name $ClusterFqdn -NoStorage -StaticAddress "$ClusterIP"

If you have multiple disks and you don’t know what is cluster disk 4 or 6 or what disk should be used for the Quorum disk ? Well I did make a selection that shows only the smallest disk that are available

#Show Cluster Disk Available
Write-Host "Show Cluster Disk Available…" -ForegroundColor yellow
Get-ClusterAvailableDisk
#Show Wittness Disk Capable
Write-Host "Show Wittness disk for Cluster Available…" -ForegroundColor yellow
Get-ClusterAvailableDisk | ?{ $_.Size -lt 1573741824}

Sure You can change this for not to put in “cluster disk 1” but use only the disk number.

# Place the Wittness disk
Write-Host "Choose a Wittness disk for the Windows 2008 R2 Cluster… Must be "Cluster Disk # "" -ForegroundColor yellow
$ClusterQuorumdisk = Read-Host "Enter Wittness disk Cluster Disk number"

# Add disks to the Cluster
Write-Host "Add disks to Windows 2008 R2 Cluster…" -ForegroundColor yellow
Get-ClusterAvailableDisk | Add-ClusterDisk

Here Is the mounting off the cluster disk and I put a sleep in it this way I make sure the disk is online

#Show Wittness Disk Capable
Write-Host "Show Wittness disk for Cluster Available…" -ForegroundColor yellow
Get-ClusterAvailableDisk | ?{ $_.Size -lt 1573741824}
Start-Sleep -Seconds 5
# Change the quorum model
Write-Host "Change the Quorum model Windows 2008 R2 Cluster…" -ForegroundColor yellow
Set-ClusterQuorum -NodeAndDiskMajority $ClusterQuorumdisk

The Second node is added If you have a four node cluster just add them here

Add-Clusternode $Clusternode2 ,$Clusternode3 , $Clusternode4

But you must also use the input section above

$Clusternode3 = Read-Host "Enter ClusterNode 3 for the new cluster"

$Clusternode4 = Read-Host "Enter ClusterNode 4 for the new cluster"

 

 

# Add Cluster node
Write-Host "Add Cluster node to Windows 2008 R2 Cluster…" -ForegroundColor yellow
Add-Clusternode $Clusternode2

You can find the Scripts Here : Powershell Scripts

Powershell Create Cluster 

Teched 2010 Berlin #TEE10 #Teched

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

  • Twitter

  • %d bloggers like this: