#Define variable - please make changes below
Write-Host "Start to collect variables" -ForegroundColor Green
#Define NIC Team Name & Count
$TN1 = "Team#01"
Write-Host "Got Team Name $TN1"
#Define NICs
$TN1NIC = "LOM#01","LAN#01","LAN#02"
Write-Host "Got Network Interfaces $TN1NIC which will be included in $TN1"
#Define variable for vSwitch
$SW1 = "CVMSWExt#1"
Write-Host "Got Name for converged switch $SW1"
#Define Default FlowMinimum Bandwidth Weight
$FMBWW ="3"
Write-Host "Got Default FlowMinimum Bandwidth Weight $FMBWW for converged switch $SW1"
#Define variable for vNICs
$MGM = "Management"
Write-Host "Got Name for Management Network "$MGM""
$LM = "LiveMigration"
Write-Host "Got Name for Livemigration Network "$LM""
$CSV = "CSV"
Write-Host "Got Name for Cluster Shared Volume & Heartbeat Network "$CSV""
$SAN = "SAN"
Write-Host "Got Name for Storage Area Network "$SAN""
#Define VLAN IDs
$VLANMGM = "99"
Write-Host "Got VLAN ID $VLANMGM for $MGM Network Interface"
$VLANLM = "20"
Write-Host "Got VLAN ID $VLANLM for $LM Network Interface"
$VLANCSV = "30"
Write-Host "Got VLAN ID $VLANCSV for $CSV Network Interface"
$VLANSAN = "40"
Write-Host "Got VLAN ID $VLANSAN for $SAN Network Interface"
#Define IPs
$IPMGM = "10.11.150.150"
Write-Host "Got IPv4 Address $IPMGM for $MGM Network Interface"
$IPLM = "10.11.152.150"
Write-Host "Got IPv4 Address $IPLM for $LM Network Interface"
$IPCSV = "10.11.153.150"
Write-Host "Got IPv4 Address $IPCSV for $CSV Network Interface"
$IPSAN = "10.11.151.150"
Write-Host "Got IPv4 Address $IPSAN for $SAN Network Interface"
#Define Subnetmask
$SNMGM = "24"
Write-Host "Got Subnetmask $SNMGM for $MGM Network Interface"
$SNLM = "24"
Write-Host "Got Subnetmask $SNLM for $LM Network Interface"
$SNCSV = "24"
Write-Host "Got Subnetmask $SNCSV for $CSV Network Interface"
$SNSAN = "24"
Write-Host "Got Subnetmask $SNSAN for $SAN Network Interface"
#Define DNS Server Management LAN
$DNSMGM1 = "10.11.150.10"
$DNSMGM2 = "10.11.150.11"
Write-Host "Got DNS Server IPv4 Address $DNSMGM1 & $DNSMGM2 for $MGM Network Interface"
#Define Default Gateway
$DGMGM = "10.11.150.254"
Write-Host "Got Default Gateway IPv4 Address $DGMGM for $MGM Network Interface"
#Define Bandwidth Weight
$BWMGM = "10"
Write-Host "Got got minimum Bandweigth $BWMGM for $MBM Network Interface"
$BWLM = "30"
Write-Host "Got got minimum Bandweigth $BWLM for $LM Network Interface"
$BWCSV = "10"
Write-Host "Got got minimum Bandweigth $BWCSV for $CSV Network Interface"
$BWSAN = "30"
Write-Host "Got got minimum Bandweigth $BWSAN for $SAN Network Interface"
#Consisten names
$VE ="vEthernet"
#Create NIC Team
Write-Host "Creating NIC $TN1 with $TN1NIC" -ForegroundColor Green
New-NetLbfoTeam -Name $TN1 -TeamMembers $TN1NIC -LoadBalancingAlgorithm HyperVPort -TeamingMode SwitchIndependent
Write-Host "NIC Team $TN1 created" -ForegroundColor Yellow
#Create VMSwitch ext for convered network
Write-Host "Creating vSwitch $SW1" -ForegroundColor Green
New-VMSwitch -Name $SW1 -NetAdapterName $TN1 -AllowManagementOS $false -MinimumBandwidthMode Weight
Set-VMSwitch $SW1 -DefaultFlowMinimumBandwidthWeight $FMBWW
Write-Host "vSwitch $SW1 created" -ForegroundColor Yellow
#Create vNICs on VMSwitch
Write-Host "Creating VM Network Adapter in Management OS $MGM, $LM, $CSV & $SAN" -ForegroundColor Green
Add-VMNetworkAdapter -ManagementOS -Name $MGM -SwitchName $SW1
Write-Host "Creating VM Network Adapter $MGM created" -ForegroundColor Yellow
Add-VMNetworkAdapter -ManagementOS -Name $LM -SwitchName $SW1
Write-Host "Creating VM Network Adapter $LM created" -ForegroundColor Yellow
Add-VMNetworkAdapter -ManagementOS -Name $CSV -SwitchName $SW1
Write-Host "Creating VM Network Adapter $CSV created" -ForegroundColor Yellow
Add-VMNetworkAdapter -ManagementOS -Name $SAN -SwitchName $SW1
Write-Host "Creating VM Network Adapter $SAN created" -ForegroundColor Yellow
#Set vNIC VLAN to switch
Write-Host "Configuring VLANs for $MGM, $LM, $CSV & $SAN" -ForegroundColor Green
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $MGM -Access -VlanId $VLANMGM
Write-Host "VLAN ID $VLANMGM assigned to VM Network Adapter $MGM" -ForegroundColor Yellow
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $LM -Access -VlanId $VLANLM
Write-Host "VLAN ID $VLANLM assigned to VM Network Adapter $LM" -ForegroundColor Yellow
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $CSV -Access -VlanId $VLANCSV
Write-Host "VLAN ID $VLANCSV assigned to VM Network Adapter $LM" -ForegroundColor Yellow
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $SAN -Access -VlanId $VLANSAN
Write-Host "VLAN ID $VLANSAN assigned to VM Network Adapter $SAN" -ForegroundColor Yellow
#Set Bandwidth to switch
Write-Host "Configuring Bandwidth Weight for $MGM, $LM, $CSV & $SAN" -ForegroundColor Green
Set-VMNetworkAdapter -ManagementOS -Name $MGM -MinimumBandwidthWeight $BWMGM
Write-Host "Assigned minimum Bandwidth to $MGM is $BWMGM" -ForegroundColor Yellow
Set-VMNetworkAdapter -ManagementOS -Name $LM -MinimumBandwidthWeight $BWLM
Write-Host "Assigned minimum Bandwidth to $LM is $BWLM" -ForegroundColor Yellow
Set-VMNetworkAdapter -ManagementOS -Name $CSV -MinimumBandwidthWeight $BWCSV
Write-Host "Assigned minimum Bandwidth to $CSV is $BWCSV" -ForegroundColor Yellow
Set-VMNetworkAdapter -ManagementOS -Name $SAN -MinimumBandwidthWeight $BWSAN
Write-Host "Assigned minimum Bandwidth to $SAN is $BWSAN" -ForegroundColor Yellow
#Set IP Address Management
Write-Host "Configuring IPv4, Subnetmask, Default Gateway and DNS Servers for $MGM" -ForegroundColor Green
New-NetIPAddress -InterfaceAlias "$VE ($MGM)" -IPAddress $IPMGM -PrefixLength "$SNMGM" -DefaultGateway $DGMGM
Write-Host "Set IPv4 Address $IPMGM, Subnet Mask /$SNMGM & Default Gateway $DGMGM to $VE ($MGM)" -ForegroundColor Yellow
Set-DnsClientServerAddress -InterfaceAlias "$VE ($MGM)" -ServerAddresses $DNSMGM1, $DNSMGM2
Write-Host "DNS Server $DNSMGM1 & $DNSMGM2 were configured on $VE ($MGM)"
#Set IP SAN, Livemigration & CSV
Write-Host "Configuring IPv4 & Subnetmask for $MGM, $LM, $CSV & $SAN" -ForegroundColor Green
New-NetIPAddress -InterfaceAlias "$VE ($LM)" -IPAddress $IPLM -PrefixLength "$SNLM"
Write-Host "Set IPv4 Address $IPLM & Subnet Mask /$SNLM to $VE ($LM)" -ForegroundColor Yellow
New-NetIPAddress -InterfaceAlias "$VE ($CSV)" -IPAddress $IPCSV -PrefixLength "$SNCSV"
Write-Host "Set IPv4 Address $IPCSV & Subnet Mask /$SNCSV to $VE ($CSV)" -ForegroundColor Yellow
New-NetIPAddress -InterfaceAlias "$VE ($SAN)" -IPAddress $IPSAN -PrefixLength "$SNSAN"
Write-Host "Set IPv4 Address $IPSAN & Subnet Mask /$SNSAN to $VE ($SAN)" -ForegroundColor Yellow