Mastering Windows Server 2016 Hyper-V

(Romina) #1
            $logicalNetworkDefinition   =   New-SCLogicalNetworkDefinition  `

-Name "VLAN_$vlanID" -LogicalNetwork $logicalNetwork -VMHostGroup $allHostGroups
-SubnetVLan $allSubnetVlan -RunAsynchronously


            #   Gateways
$allGateways = @()
$allGateways += New-SCDefaultGateway -IPAddress "10.1.$vlanID.1" `

-Automatic


            #   DNS servers
$allDnsServer = @("10.1.$vlanID.10", "10.1.$vlanID.11")

# DNS suffixes
$allDnsSuffixes = @()

# WINS servers
$allWinsServers = @()

$NewVLANName = "VLAN_" + $vlanID + "_IP_Pool"

New-SCStaticIPAddressPool -Name $NewVLANName `

-LogicalNetworkDefinition $logicalNetworkDefinition -Subnet "10.1.$vlanID.0/24"
-IPAddressRangeStart "10.1.$vlanID.10" -IPAddressRangeEnd "10.1.$vlanID.11"
-DefaultGateway $allGateways -DNSServer $allDnsServer -DNSSuffix "" `
-DNSSearchSuffix $allDnsSuffixes -RunAsynchronously


            #Now    create  VM  Network for each

$vmNetwork = New-SCVMNetwork -Name "Customer_VLAN_$vlanID" `

-LogicalNetwork $logicalNetwork -IsolationType "VLANNetwork" -Description "VM Network for Customer VLAN $vlanID" $logicalNetworkDefinition = Get-SCLogicalNetworkDefinition
-Name "VLAN_$vlanID"
$subnetVLAN = New-SCSubnetVLan -Subnet "10.7.$vlanID.0/24" -VLanID $vlanID $VMSubnetName = "Customer_VLAN_" + $vlanID + "_0" $vmSubnet = New-SCVMSubnet -Name $VMSubnetName
-LogicalNetworkDefinition $logicalNetworkDefinition -SubnetVLan $subnetVLAN
-VMNetwork $vmNetwork


            $vlanID +=  1

}
until ($vlanID -gt $endNumber)


CREATING THE PORT PROFILES AND LOGICAL SWITCH


Now that the logical networks and VM networks exist, you can create my logical
switch. Remember, however, that the logical switch uses the uplink port profiles to
identify the connectivity available. You also use virtual port profiles and port

Free download pdf