Sunday, February 1, 2015 6:58 AM
Who's the king? Of course PowerShell. Let's try to use its beauty to create 3 node failover cluster. It's nothing unusual, where is this beauty? In remoting of PowerShell scripts. RDP is for noobs. Geeks(withBlogs) do such tasks this way:
# Install Failover Clustering and File Server Roles
Invoke-Command -ComputerName Server1, Server2, Server3 -ScriptBlock
{
Get-WindowsFeature *Cluster* | Add-WindowsFeature –includeManagementTools
Get-WindowsFeature *File-Services* | Add-WindowsFeature –includeManagementTools
Get-WindowsFeature *FS-FileServer* | Add-WindowsFeature –includeManagementTools
}
# Configure the iSCSI Targert with Initiator ID's
Set-IscsiServerTarget -ComputerName DC -TargetName Contoso-ISCSI-SAN -InitiatorIds `
"Iqn:iqn.1991-05.com.microsoft:serverl.contoso.com", `
"Iqn:iqn.1991-05.com.microsoft:server2.contoso.com", `
"Iqn:iqn.1991-05.com.microsoft:server3.contoso.com"
# Connect iSCSI Targets
Invoke-Command -ComputerName Server1, Server2, Server3 -ScriptBlock
{
New-IscsiTargetPortal -TargetPortalAddress 10.0.0.1
Connect-IscsiTarget -NodeAddress (Get-IscsiTarget).NodeAddress -IsPersistent:$True
}
# set physical iSCSI Disks to Online
Invoke-Command -ComputerName Server1 -ScriptBlock {
$Disks=Get-Disk | where isOffline
foreach ($Disk in $Disks) {
Set-Disk -Number $disk.Number -IsReadOnly 0
Set-Disk -number $disk.Number -IsOffline 0
Initialize-Disk $disk.Number -PartitionStyle MBR
$Part = New-Partition -DiskNumber $disk.Number -UseMaximumSize -AssignDriveLetter
Initialize-Volume -DriveLetter $part.DriveLetter -FileSystem NTFS -Confirm:$False
}
# Loop through volumes and catch format failures, then retry.
do {
[Array]$Volumes = Get-Volume | Where FileSystem -eq ''
Foreach ($vol in $Volumes) {
Initialize-Volume -DriveLetter $Vol.DriveLetter -FileSystem NTFS -Confirm:$False
}
} while ($Volumes.Count -gt 0)
}
# create the cluster
Invoke-Command -ComputerName Server1 -ScriptBlock {
Test-Cluster –Node Server1, Server2, Server3
New-Cluster -Name MyCluster -Node Server1, Server2, Server3
#let's create a ScaleOutFileServer
Get-ClusterAvailableDisk | ?{ $_.ScsiAddress -eq 50331651 } | Add-ClusterDisk
Add-ClusterSharedVolume "Cluster Disk 2"
#Add-ClusterFileServerRole -Storage "Cluster Disk 2" -Name myCluster
Add-ClusterScaleOutFileServerRole -Name "Cluster-SOFS"
Move-ClusterGroup -Name Cluster-SOFS -Node Server1
#$volumes = Get-Volume | where filesystem -eq CSVFS
md c:\ClusterStorage\Volume1\UserDocs
New-SmbShare -Name UserDocs -Path c:\ClusterStorage\Volume1\UserDocs -FullAccess Contoso\Administrator
}
Let's check results ….
