Setting up Hyper-V lab using Powershell


In this post I setup a Hyper-V lab to test VM performance on Gridstore enterprise storage array.

Hardware: Compute node (Hyper-V host): 2x Xeon E5-2430L CPUs at 2 GHz with 6 cores each (12 Logical processors) and 15 MB L3 cache, 96 GB RAM, 2x 10Gbps NICs that are not RDMA capable. Storage is 8x LUNs from a 6-node Gridstore array detailed in this post.

I have Hyper-V role installed on this server. Next I setup NIC team and a vSwitch using this script:

GS-vSwitch

# Script to create NIC team, vSwitch
# Sam Boutros
# 6/28/2014
#
$PhysicalNICs = “NIC1,NIC2” # Get these names from Get-NetAdapter command
$NICTeamName = “Team1”
$vSwitchName = “My_vSwitch” # Pick a name for your vSwitch
$ParentPartitionvNICName = “My_vNIC” # Pick a name for your PP vNIC
$VLAN = 19
# End Data Entry section
#
# Create NIC Team
New-NetLbfoTeam -Name $NICTeamName -TeamMembers $PhysicalNICs -LoadBalancingAlgorithm HyperVPort -TeamingMode SwitchIndependent
# Create vSwitch
New-VMSwitch -Name $vSwitchName -NetAdapterName $NICTeamName -AllowManagementOS $False -MinimumBandwidthMode Weight
Set-VMSwitch $vSwitchName -DefaultFlowMinimumBandwidthWeight 50
# Create vNIC on this new vSwitch for the parent partition (Hyper-V host OS)
Add-VMNetworkAdapter -ManagementOS -Name $ParentPartitionvNICName -SwitchName $vSwitchName
# Comment out the following line if you’re not using VLANs
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $ParentPartitionvNICName -Access -VlanId $VLAN

Using a previously sys-prepped server 2012 R2 VHDX file (golden image), I manually create a VM to be used as DC for new lab test domain and DHCP server.

Install Active Directory Domain Services, DNS server, and DHCP server roles.

Configure Active Directory: new forest, new domain, forest level and domain level: 2012 R2, reboot.

Authorize DHCP server:

GS-010b

Create, configure, and activate new DHCP scope:

GS-010c

GS-010d

I got/set the MAC addresses to be given out by my Hyper-V host:

GS-010e

I added an Allow Filter to ensure that this DHCP server gives out IPs to the VMs of this host only and not any other machine in VLAN 19:

GS-010f

Now we’re ready to spin some VMs!

See this post for a script to create many VMs in bulk.

And this post for renaming them and joining them to the domain.

Advertisements

One response

  1. Pingback: Powershell script to rename many computers and join them to AD domain | Sam's Corner

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s