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:


# 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:


Create, configure, and activate new DHCP scope:



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


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:


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.


5 responses

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

  2. If you can, write me an Email and we can discuss because I have an idea you will like. I needed this. I will like your other websites. I was reading your article while chillin at my coffee shop.

    August 30, 2017 at 10:51 pm

  3. Kudos. excellent post, thanks a lot. I never discovered any attention-grabbing post like yours. Thank you again.

    August 31, 2017 at 3:14 pm

  4. Super weird… when I turned on my lap top your website was already loaded. I am on the same side as you. Thank you for sharing your info. I bookmarked it to my bookmark site list and will be checking back soon. It is like you read my thoughts!

    September 1, 2017 at 10:03 pm

  5. I am going to follow you on Twitter. You should be beyond proud of yourself. Your blog has a certian feeling about it. You are my savior.

    September 2, 2017 at 7:15 pm

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.