1 # Install the Hyper-V Role (may require a reboot)
2 # Install the Failover Clustering Feature
3
4 Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools
5 Install-WindowsFeature -Name Hyper-V -IncludeManagementTools
6 ## do restart after the MPIO settings which require a restart
7
8 Get-Module -ListAvailable -Name Hyper-V
9 Get-Module -ListAvailable -Name Failover-Clustering
10
11 ########### MANAGEMENT NETWORK ############
12 #create the management SET switch
13 New-VMSwitch -Name "vSwitch-Mgmt" `
14 -NetAdapterName "Mgmt-A", "Mgmt-B" `
15 -EnableEmbeddedTeaming $true `
16 -AllowManagementOS $false
17
18 Add-VMNetworkAdapter `
19 -ManagementOS `
20 -Name "HyperV-Mgmt" `
21 -SwitchName "vSwitch-Mgmt"
22
23 #Assign your management IP/DNS to that vNIC
24 New-NetIPAddress `
25 -InterfaceAlias "vEthernet (HyperV-Mgmt)" `
26 -IPAddress [Link] `
27 -PrefixLength 24 `
28 -DefaultGateway [Link]
29
30 Set-DnsClientServerAddress `
31 -InterfaceAlias "vEthernet (HyperV-Mgmt)" `
32 -ServerAddresses ("[Link]", "[Link]")
33
34 #Rename the adapter that was automatically created (Friendly/GUI name)
35 #Rename-NetAdapter -Name "vEthernet (vSwitch-Mgmt)" -NewName "HyperV-Mgmt (vSwitch-Mgmt)"
36
37
38
39 ########### CLUSTER NETWORK ############
40 #The Cluster Network (used for Cluster Heartbeats and internal communication)
41 New-VMSwitch `
42 -Name "vSwitch-Cluster" `
43 -NetAdapterName "Cluster-A","Cluster-B" `
44 -EnableEmbeddedTeaming $true `
45 -AllowManagementOS $false
46
47 Add-VMNetworkAdapter `
48 -ManagementOS `
49 -Name "HyperV-Cluster" `
50 -SwitchName "vSwitch-Cluster"
51
52 #Assign IP to cluster adapter (no gateway needed)
53 New-NetIPAddress -InterfaceAlias "vEthernet (HyperV-Cluster)" `
54 -IPAddress [Link] -PrefixLength 24
55
56 #Rename the adapter that was automatically created (Friendly/GUI name)
57 #Rename-NetAdapter -Name "vEthernet (vSwitch-Cluster)" -NewName "HyperV-Cluster
(vSwitch-Cluster)"
58
59
60
61 ########### LIVE MIGRATION NETWORK ############
62 ## the LM vlan will be on the Cluster NICs, so will create new VM net adapter for LM on
the same VMSwitch
63 Add-VMNetworkAdapter `
64 -ManagementOS `
65 -Name "HyperV-Cluster" `
66 -SwitchName "vSwitch-Cluster"
67
68 #tag the vlan for LM
69 Set-VMNetworkAdapterVlan `
70 -ManagementOS `
71 -VMNetworkAdapterName "HyperV-LiveMig" `
72 -Access `
73 -VlanId 202
74
75 #assign the IP Address
76 New-NetIPAddress `
77 -InterfaceAlias "vEthernet (HyperV-LiveMig)" `
78 -IPAddress [Link] `
79 -PrefixLength 24
80
81 #Rename the adapter that was automatically created (Friendly/GUI name)
82 #Rename-NetAdapter -Name "vEthernet (HyperV-LiveMig)" -NewName "HyperV-LiveMig
(vSwitch-Cluster)"
83
84
85
86
87 ########### VM NETWORK (Front end) ############
88
89
90 New-VMSwitch `
91 -Name "vSwitch-VMNet" `
92 -NetAdapterName "VMnet-A","VMnet-B" `
93 -EnableEmbeddedTeaming $true `
94 -AllowManagementOS $false
95
96
97 ################### Build / Add hosts to cluster #################
98
99 $Nodes = "HV21-2", "HV21-8"
100 Test-Cluster -Node $Nodes -Include "Inventory", "Network", "Storage" -ReportName
"ClusterValidationReport_$(Get-Date -Format yyyyMMdd)"
101
102
103 ############### MISC COMMANDS ###################
104
105 #list vSwitches
106 Get-VMSwitch
107
108 #list interfaces/interfaceAlias
109 Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, InterfaceAlias
110
111 #to list all VM Net Adapters (non VMs)
112 Get-VMNetworkAdapter -ManagementOS
113 Get-VMNetworkAdapterVlan -ManagementOS
114
115 #to delete VMSwitch
116 Remove-VMSwitch -Name "vSwitch-Cluster" -Force
117
118 # Get a list of the paths MPIO is managing for a specific disk
119 Get-MSDSMDevice -PersistentStorageIdentifier "PURE FlashArray" | Get-MPDisk | Get-MPPath
120
121 (Get-ClusterNetwork "Cluster Network 1").Name = "HyperV-Mgmt"
122 (Get-ClusterNetwork "Cluster Network 2").Name = "vSwitch-Cluster"
123 (Get-ClusterNetwork "Cluster Network 3").Name = "HyperV-LiveMig"