Create and destroy Logical Networks with powershell in SCVMM 2012

I am at a customer and setting up an new environment with Hyper-V hosts and SCVMM 2012 RC, we have succesfully created host-vhd and got bare-metal deploy working including HP PSP software and NIC-Teaming configuration. The hosts are deployed with Windows 2008 R2 Datacenter Core SP1 on HP BL460c G7 blades with flexfabric and an EMC SAN delivers the disks.

Now we had to get the network configured, the customer has several VLANs and i have configured the Hyper-V hosts with the HP nic team tool and have two teamed NICs for the VM traffic. To not have to configure one virtual nic/switch for each VLAN i have enabled promiscuous mode.

Now to make it easier we create a bunch of Logical Networks with some powershell in the SCVMM 2012 powershell console, this because setting up 20 networks manually and also associate them on every host in the cluster is kind of boring, cause if i do not associate the logical networks to the hosts VM adapter i can not assign them on the VMs.

So what does the script look like, the help info from SCVMM powershell console and also view script button in the helps allot when trying to find out what i need to make it work. There are some differences in the cmdlets between vmm 2008 r2 and the 2012 rc.

# Create SCVMM virtual networks and associate them with hosts
# Niklas Akerlund /RTS

$VLANs = Import-Csv vlan1.csv -Delimiter ";"
$VMHostGroup = Get-SCVMHostgroup
$VMHosts = Get-SCVMHost
$LogicalNetworks = @()
foreach ($VLAN in $VLANs){
    $LogicalNetwork = New-SCLogicalNetwork -Name $VLAN.Name
    $LogicalNetworks += $LogicalNetwork
    $Network = $VLAN.IPnet + $VLAN.Octet
    $SubnetVlan = New-SCSubnetVLan -Subnet $Network -VLanID $VLAN.VLAN
    New-SCLogicalNetworkDefinition -Name $VLAN.Name -LogicalNetwork $logicalNetwork -VMHostGroup $VMHostGroup -SubnetVLan $SubnetVlan

foreach ($VMHost in $VMHosts){   
    $vmHostNetworkAdapter = Get-SCVMHostNetworkAdapter -Name "VM" -VMHost $VMHost
    foreach ($LogicalNet in $LogicalNetworks){
        Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $vmHostNetworkAdapter -AddOrSetLogicalNetwork $logicalNet

After running the script it looks like this in the properties on one Logical Network.

After this i also want to be able to remove the Logical Networks (or at least some) when they are not needed anymore, As there are some dependencies we have to remove these first and at last the Logical Network

# Remove Logical Networks from SCVMM2012
# Niklas Åkerlund /RTS

$VLANs = Import-CSV vlan1.csv -Delimiter ";"
$VMHosts = Get-VMHost

foreach ($VLAN in $VLANs){
    $LogicalNetwork = Get-SCLogicalNetwork $VLAN.Name
    if ($LogicalNetwork -ne $null){
        foreach ($VMHost in $VMHosts){
            $VMHostNetworkAdapter = Get-SCVMHostNetworkAdapter -Name "VM" -VMHost $VMHost
            Set-SCVMHostNetworkAdapter -VMHostNetworkAdapter $VMHostNetworkAdapter -RemoveLogicalNetwork $LogicalNetwork
        $LogicalNetworkDefinition = Get-SCLogicalNetworkDefinition -LogicalNetwork $LogicalNetwork 
        Remove-SCLogicalNetworkDefinition -LogicalNetworkDefinition $LogicalNetworkDefinition
        Remove-SCLogicalNetwork -LogicalNetwork $LogicalNetwork

To get some more information about the powershell cmdlets look at this reference site.

Hyper-V R2 Core host networking problem in VMM 2008 R2

This Friday i helped a customer with a little problem, they have a Hyper-V cluster with 4 nodes, after a switch firmware upgrade they experienced some networking instability and in their search of failure they accidentally unchecked the Host access checkbox in the networking properties on the net, as their networking configuration did not allow a separate nic for the management we had to set it up with this enabled. Of course when they applied this change the host lost connection.

I instructed them to use the 59manager to configure the host locally and set the host access on this virtual switch, this did not help cause the server would still not respond. I went over to help them on site, the first thing we did was to remove the host from the cluster and then start to test and when we removed the virtual switch the nic started to respond to ping but as soon as we re-added it to the virtual switch it stopped working. We also tried to remove the nic config and set it to dhcp and then add it to the virtual switch with the host access enabled, which did not work either. After this when we tried to set the IP in SCONFIG we got an error that stated that there was an error and the address could not be set. I thought it might be some bug in the team networking sw or drivers so we updated those as well, but no more luck there either..

Then we found the following site that described the exact same problem, Microsoft Enterprise Networking Team , in this blog they referred to a script that clean out the whole hosts virtual networking config, “nvspcrub.js” , with the /p option. Well we had to try something so we ran the script and cleared the hosts all virtual switches.  Then we added a new virtual switch and checked the Host access and tried to set the IP in SCONFIG, Still same error with “Can not set IP address”, After this we where almost on our way to give up and reinstall the host, then we thought of one last chance to set the IP through netsh (this after reading about a bug with SCONFIG) so with the command

netsh int ip set add "Local area connection 3" static

It actually worked and the host started to respond to ping 🙂 , quite frustrating that we removed all the config and then find out it was a bug in sconfig that was the causing the error.

Now we had to re-add all virtual networking switches, this was of course a perfect job for powershell, so i wrote a script that took one of the other hosts config and created the same virtual switches on the failed host, also connecting to the NIC corresponding to the right net and vlan

# Create Virtual Networks on Host
# Niklas Akerlund /RTS

# Take ref nic from another host

Add-PSSnapin Microsoft.SystemCenter.VirtualMachineManager
$VMMserver = Get-VMMServer sbgvmm01

$Networks = Get-VirtualNetwork | where {$_.VMHost -eq "" -and $_.HostBoundVlanId -ne "3750"}

$NICs = Get-VMHostNetworkAdapter | where {$_.VMHost -eq ""}

$VMHost = Get-VMhost -ComputerName ""

foreach($Network in $Networks){
$split = $Network.Name -split ' '
if ($split[1] -eq "1"){
$Name = $split[0] + " " + $split[1]
$match = $split[2] -match "\d+"
$vlanid = $Matches[0]
$vlanid = [int]$vlanid
}elseif ($split[1] -like "VLAN*"){
$Name = $split[0]
$match = $split[1] -match "\d+"
$vlanid = $Matches[0]
$vlanid = [int]$vlanid
$Name = $split[0] + " " + $split[1]
$match = $split[2] -match "\d+"
$vlanid = $Matches[0]
$vlanid = [int]$vlanid

$HostNIC = Get-VMHostNetworkAdapter -VMHost $VMHost | where {$_.ConnectionName -eq $Name}

if ($HostNIC -ne $null){

New-VirtualNetwork -Name $Network.Name -VMHost $VMHost -VMHostNetworkAdapters $HostNIC -BoundToVMHost $FALSE
Set-VMHostNetworkAdapter -VMHostNetworkAdapter $HostNIC -VLANEnabled $TRUE -VLANMode "Trunk" -VLANTrunkID $vlanid
write-host $HostNIC.ConnectionName
Write-Host $vlanid

After i ran this and the host got all it´s virtual networks back i could add the host back to the cluster again. Instead of some typo errors with manually entering all the virtual switches, with some powershell we could be sure that we got the same config as the other host already in the cluster!

One thing that i first missed was the -BoundToVMHost $FALSE in the New-VirtualNetwork which resulted that all my virtual networks had the Host Access checkbox marked and i had one NIC for each of them on my host, this of course was not what i wanted, one could think that this would be false as default but for some reason MS and the VMM team thought different, well no worries i created a small script to just update my virtual networks with that option (the script above is corrected after my mistake), so i ran:

# Update networks with BoundtoHost $false
# Niklas Akerlund /RTS

$Networks = Get-VirtualNetwork | where {$_.VMHost -eq "" -and $_.HostBoundVlanId -ne "3750"}

foreach ($Network in $Networks){
Set-VirtualNetwork -VirtualNetwork $Network -BoundToVMHost $false

Where the network with the VLAN 3750 was the one i wanted the host access to stay because it was the management nic of the host.

TEC 2011 Successfully implement and Transition into Hyper-V Session

Some summary based on my own session i held at The Experts Conference 2011 in Frankfurt yesterday. I think it was about 40 people in the crowd. The TEC is about 350 attendees total.

When i have checked with Quest if i can put my whole presentation here i will do an updated posting, i will put some points what i think is crucial when setting up a new vitualization platform.

  • Assessment and Consolidation Planning
  • Design and Testing
  • Migration and Optimization
  • Capacity Planning and Performance follow up

When deciding for a new virtualization platform, no matter if it is the first or you are going to exchange an existing, there are some steps that need to be considered. First you have to know what you are running in your datacenter, what kind of operating systems and what kind of applications, also you must get a workload profile for those servers to know what their demands are. If you do not do your homework and plan for the load you will surely get some beating from your organization when you have virtualized the servers and they run like crap. As tools you can use the Microsoft Assessment and Planning Toolkit or if you already use SCCM/SCOM you will both have inventory and performance data. Another thing to consider when planning is licensing, in a big consolidation you can save quite a much money when using Datacenter licensing on the hosts.

Design your platform to be modular and easily expanded. Do serious deciding on what your boundaries are both technically and financially this should be done in a workshop with application owners and management and then documented. Do not forget about managing and monitoring software. Another thing to rethink is how to take backup in your platform, with Hyper-V integration tools you can take consistent backups with VSS snapshot support into the VMs, we recommend our customers to take backup on host level for quicker RTO. When you have decided for a platform you can do a PoC to test your decisions and see that it works as expected, Many hardware manufacturers do lend out hw for you to test for a limited time to evaluate.

When the platform is set up and correctly configured you want to do some hardware and load testing, there are several tools for this. Memtest, IOmeter, SQLiosim, Exchange jetstress, Exchange Load Gen and others. The most important thing to consider here is that you want to check that your new platform can handle the load you did measure and predict for in the analysis and design. Also test fail-over functionality so that all hardware and software works as expected when a PSU or a network cable brakes. After all testing has successfully been made you want to document this for later so you have a validation document signed.

After you have a platform set up and tested you want to start migrate and optimize workloads into this. There are some tools that can be used for this, SCVMM, disk2vhd and Quest vConverter for example. One thing to consider when doing migration is to look back at the analysis of the workloads to set the right amount of resources, both virtual processors/vm ram and vhd disk files with the partitions inside (for best performance we would like to use fixed or pass-through disks). When optimizing after migration you want to clean out hidden devices and services/software that was used for the machine in the physical world but do not have a purpose anymore!

When all your machines are migrated we want to continuously check the performance and capacity so you can prepare and implement additional host resources before it runs out. You can use SCOM/SCVMM if you have it in your environment, another great performance tool is the PAL (Performance Analysis of Logs ) that you can use in conjuction with performance counters and logman to schedule datasets on your Hyper-V Core host servers, also there is a product from Quest, vFoglight.

the last slide i had a strip from Dilbert that i find quite funny, statement though: WE DO NOT LEAVE OUR CUSTOMERS AS DOGBERT DOES AFTER A virtualization Project 😛


MAP 6.0



Performance tuning win 2008 R2 SP1


Win 8 Server dev preview and Hyper-V NIC team

There is quite a buzz out on twitter and blogs about the new features that has come to Windows 8 and the new Hyper-V version. I want to give you a little heads up about how it works to create network team with NICs (yes it works with different nic cards. in my case a Intel and a Broadcom)

I have now installed the server on my test-machine in our office and was eager to test the NIC teaming, at first i did not understand how it was working and tried to bind two nics together in the network connections window in the control panel, as i later realized and read in Aidan Finns´s blog, that it is done through the LBFOAdmin.exe (this is opened when pressing Nic Teaming Enabled/Disabled)

There you have to highligt your server to configure it, as the new server manager can handle remote servers and you can configure several workloads at the same time and you do not have to log in to each server to administer it.

I have named my team to NET2000 and added the two nics, i have also set it to be switch independent (i have actually set it in a simple 5 port switch), you can also chose LACP or Static Teaming. For Load Distribution mode you can chose Address Hash or Hyper-V port (now i am sharing the team with the management and a hyper-v switch so i am using the Address Hash.

As yo can see i can then add several virtual nics with different vlan id. I really hope that the fix one issue though, as you can see here i have a virtual nic interface called VMnet, when i then want to add this in the hyper-v manager it does have a different name as you can see in the next screenshot. It would have been wonderful to be able to se the Name also in the virtual switch manager.

As i before had to use the same network cards from the same manufacture and use their teaming software this is a giant step forward with the win 8 and the built in teaming functions. One thing to test later when i get my hands on a nic that can handle SR-IOV is how that feature works with a team, but that is  another blog post!


Certification MCITP: Virtualization Administrator

Today i took the 70-669 exam to become Windows Server 2008 R2 Desktop Configuration Technology Specialist, it was a little hard in some areas cause some of the questions was on MED-V that i have not so much experience in, but APP-V and Presentation virtualization was a bit easier. As always with the exams, read the question thoroughly and think about what they want and then look at the answers.

On tuesday i took the 70-693 PRO exam. and last year i took the 70-659 so now i am MCITP: Virtualization Administrator.

here is a graph of the path to become MCITP: Virtualization Administrator:

I have worked quite a lot with Hyper-V and System Center products and to study for the Desktop Virtualization i found this page and also used a free ebook to read, there are lots of free information on the internet and also some courses. The post that i wrote about earlier this month about the Microsoft Jumpstart videos also gives good information.

i have been teaching this 10215A on Addskills that is the course for Implementing and Managing server virtualization and i can recommend it for interested technicians that want to get to know the Microsoft virtualization technologies on server and presentation.

The course 10324A for Implementing and managing Desktop virtualization is quite new and i have not looked at it yet and as far as i know, no course centers offer it as of today at least not in Sweden.

Good luck in taking the exams! With the Second shot that Prometic offers at least some of the preasure is off your back to succeed the first time 🙂 although i have never had to use it …

5Nine Manager free for Hyper-V

I found a blog post about the 5Nine Manager for Hyper-V, the cool part about this tool is that it can be run on the Server Core installation and provide a GUI for management of the Hyper-V role and the virtual machines. If for example your host has problems and has network connectivity issues this tool can be handy and use to for example check the eventlog on the core server. It is developed on the Hyper-V public API´s and coded in .Net. The best part is that it is free, there is a 99 $ licensed edition where you also in Core can access the virtual machines console and configure hyper-v networking, but the free version is enough when in troubleshooting a failing host.

Features and Benefits:

  • Hyper-V Management – 5nine Manager for Hyper-V allows managing virtual machines, virtual hard disks and networks on both local and remote Hyper-V servers. Use 5nine Manager for Hyper-V to manage Hyper-V on Windows 2008 R2 core and Hyper-V Sever installations without resorting to remote management via the Microsoft Hyper-V Manager or Virtual Machine Manager Server. 5nine Manager for Hyper-V can also be used to administer Hyper-V R2 hosts joined to a domain that is managed by a guest operating system, thus overcoming cyclic dependency issues.
  • Network Management – 5nine Manager for Hyper-V provides comprehensive virtual network management as well as the management of virtual connections and bindings. Use 5nine Manager for Hyper-V to troubleshoot and fix network connections and related problems that cannot be fixed via remote management. 5nine Manager for Hyper-V Virtual Network Manager also allows reviewing and editing virtual network ports used by the virtual network interfaces and guests.
  • Secure your Hyper-V Hosts – 5nine Manager for Hyper-V does not extend a potential attack surface on managed Hyper-V servers and does not install or require any additional components.
  • Simple and Easy to Use – 5nine Manager for Hyper-V offers a simple and easy to use User Interface that is familiar to most of Windows 2008 Server users. In addition to this, 5nine Manager for Hyper-V further simplifies the administration tasks on Windows 2008 core installations and Hyper-V Server 2008 R2 by providing a Graphical User Interface for file system views and operations.
  • Maximize Host Performance – 5nine Manager for Hyper-V has a small memory footprint and does not consume any resources on managed Hyper-V servers when it is not running.
  • Follow Best Practices – 5nine Manager for Hyper-V is a valuable tool for managing the virtualization stack on production environments that are utilizing Windows 2008 R2 Server core installations according to Microsoft Best Practices as well as the Microsoft Hyper-V Server 2008 R2.

HP Blade 460c G7 strange issues

Today i have been helping a customer with their Hyper-V R2 Cluster and patching it with the hotfix for westmere processor. one strange issue was that we found two of the blades reporting only 36 GB RAM, while the others correctly showed 72 GB RAM. As it was another consultant that was responsible for assembling the servers we first thought that they had missed to put in all DIMMs, when we loooked in the servers all slots where filled? And when we put it back in the chassi and powered on the server correctly showed 72 GB RAM! really strange.

after boot:

i used the following powershell commands in VMM powershell console to get the memory for the cluster nodes:

Get-VMHostCluster -name cluster01
Get-VMHost -VMHostCluster $VMCluster | ft Name, TotalMemory

If this happens again we will report it to the HP Support, (Edit) it happend again now..  it seems to be related to a reboot of the hosts 🙁

Microsoft Virtualization Jumpstart videos for VMware Professionals

On Technet Edge there is a couple of videos for Virtualization admins to learn more about how Microsoft Virtualization solution works.

It is a very good way to get up to speed what Microsoft has to offer and that it is a competitive solution!

from the jumpstart site:

About this Jump Start series:

The “Microsoft Virtualization for VMware Professionals” Jump Start is specially tailored for VMware and Microsoft virtualization technology pros. This cutting-edge course features expert instruction and real-world demonstrations of Hyper-V, many components of the System Center Suite, including VMM 2012, and a myriad of VDI solutions. This course is designed for Data Center Managers, IT Professionals, IT Decision Makers, Network Administrators, Storage/Infrastructure Administrators & Architects. Expert IT infrastructure consultant, Corey Hynes, and Microsoft Technical Evangelist, Symon Perriman, leveraged an engaging “team teaching” approach which makes the class as entertaining as it is educational.

Click here to watch the complete video series


Hyper-V 2008 R2 hotfix CSV redirect


on one of the blogs i am following, Adian Finn, he has a post about a new hotfix from Microsoft that has come out regarding a problem with Hyper-V clusters and CSV volumes in redirected mode, read more at this link and get the hotfix

Stop error 0x0000007a occurs on a virtual machine that is running on a Windows Server 2008 R2-based failover cluster with a cluster shared volume, and the state of the CSV is switched to redirected access

Consider the following scenario:

  • You enable the cluster shared volume (CSV) feature on a Windows Server 2008 R2-based failover cluster.
  • You create a virtual machine on the CSV on a cluster node.
  • You start the virtual machine on the cluster node.
  • You move the CSV owner to another cluster node, and you change the state of CSV to redirected access.
  • The connection that is used for redirected access is switched to another connection when one of the following scenarios occurs:
    • The cable for local area network (LAN) is disconnected.
    • The related network adapter is disabled.
    • The connection is switched by using Failover Cluster Manager.

In this scenario, you receive a Stop error message that resembles the following in the virtual machine:

STOP 0x0000007a ( parameter1 , parameter2 , parameter3 , parameter4 )


  • The parameters in this Stop error message vary, depending on the configuration of the computer.
  • Not all “0x0000007a” Stop error messages are caused by this issue.
  • You may also receive other Stop error messages when this issue occurs. For example, you may receive a “0x0000004F” Stop error message.

Playing around with Powershell and SCVMM 2012 beta and Hyper-V R2


Have been playing a little with powershell and SCVMM2012 and with these simple lines i add 64 SCSI vhd drives á 4 GB each and then delete them all while the VM is running

$VM = Get-VM -Name "VMc2test"

for ($i=0;$i -le 63;$i++){

$vhdfilename = "vhdtest" + $i
New-VirtualDiskDrive -VM $VM -Dynamic -Filename $vhdfilename -sCSI -Size 4000 -Bus 0 -LUN $i

and to delete them

$vhds = @(Get-VirtualDiskDrive -VM vmc2test | where {$_.BusType -match "SCSI"})

foreach ($vhd in $vhds){

Remove-VirtualDiskDrive -VirtualDiskDrive $vhd


and why did i select the ones that had SCSI in the remove part, well the system vhd where the OS resides is on the IDE controller so i can safely assume that the OS will still be accessible, as some of you already know in Hyper-V the boot volume must reside on a IDE controller for the VM to boot.