Posted on Leave a comment

Hyper-V Failover Cluster: Powershell

Summary of PowerShell cmdlets

Consider scripting this to save time! In the following, you would edit the variables to suit your environment, then execute the script. That means anywhere you see $VariableName=”<Something>”, you would simply replace the <Something> that appears between quotes with what you’d like to name that something–I have examples/suggestions included behind the hashtags at the end of these lines.

#To begin setup of the server (modify and run for each server):

$ComputerName="NameYourHyperVHost" # (e.g. "HVC-Node1")
Rename-Computer -NewName $ComputerName -Confirm:$False
Install-WindowsFeature –Name Hyper-V -IncludeManagementTools -NoRestart -Confirm:$False
Install-WindowsFeature -Name Failover-Clustering –IncludeManagementTools -Confirm:$False
Enable-WindowsOptionalFeature –Online –FeatureName MultiPathIO

#For the CSV Network:

$CSVAlias="NetworkAdapterForCSV"  # (e.g. "Ethernet 3")
$CSVIP="CSVIPAddress" # (e.g. "")
New-NetIPAddress -InterfaceAlias $CSVAlias -IPAddress $CSVIP -PrefixLength 24

#Setup the NIC Team & Virtual Switch:

$NIC1="Adapter1Name" # (e.g. "Ethernet")
$NIC2="Adapter2Name" # (e.g. "Ethernet 2")
$TeamName="NICTeamName" # (e.g. "HVTeam")
$SwitchName="VirtualSwitchName" # (e.g. "HVSwitch")
New-NetLbfoTeam -Name $TeamName -TeamMembers $NIC1,$NIC2 -Confirm:$false
New-VMSwitch -Name $SwitchName -NetAdapterName $TeamName

#Configure the Management Network:

$MgmtAlias="NetworkAdapterNameForMgmt" # (e.g. "vEthernet (HVSwitch)")
$MgmtIP="ManagementOSIPAddress" # (e.g. "")
$Gateway="GatewayIPAddress" # (e.g. "")
$DNS="ADDNSServerIPAddress" # (e.g. "")
New-NetIPAddress -InterfaceAlias $MgmtAlias -IPAddress $MgmtIP -PrefixLength 24 -DefaultGateway $Gateway
Set-DnsClientServerAddress -InterfaceAlias $MgmtAlias -ServerAddresses $DNS

#Join the Domain:

$Domain="DomainName" # (e.g. "Company.local")
$User="UserName" # (e.g. "hvadmin")
Add-Computer -Credential $Domain\$User -DomainName $Domain

#Setup the cluster:

$ClusterName="<ClusterName>" # (e.g. "HVCluster")
$ClusterIP="<ClusterIPAddress>" # (e.g. "")
$Node1="<HostName1>" # (e.g. "HVC-Node1")
$Node2="<HostName2>" # (e.g. "HVC-Node2")
New-Cluster -Name $ClusterName -Node $Node1,$Node2 -StaticAddress $ClusterIP -NoStorage
Leave a Reply

Your email address will not be published. Required fields are marked *