Configuring VMM logical switch with bandwidth limit virtual port

I got a question from a customer how they could limit a VM´s bandwidth from VMM as it was too noisy and devoured the bandwidth from the host for the other VM´s. There are both a way to set priority and also bandwidth in Hyper-V 2012 and later.

In Hyper-V Manager you can find the setting on the VM´s configuration and the virtual network adapter tab,

Screen Shot 2015-01-16 at 16.15.32

And here I can enable bandwidth management and set both a minimum and maximum, and in this case I want just a limit

Screen Shot 2015-01-16 at 16.15.13

But how do I accomplish the same in VMM? As you might have noticed there is no possibility to edit this on the VM´s settings on the virtual nic, this is a setting that I configure with a Port profile instead and apply on selected VM/VM´s, and by doing it this way I can easily just configure the same profile for several VM´s instead of configuring each VM. There are some configured by default and I can also add new with the particular setting that I need.

First there is the port classification:

Screen Shot 2015-01-17 at 15.49.49

And then the actual port profiles:

Screen Shot 2015-01-17 at 15.48.26

These two combined is used in the Logical Switch for the virtual port,

Screen Shot 2015-01-19 at 11.45.23

Easiest is to use Powershell to create a new port classification and profile and then update the logical switch to be able to use it for the VM´s that needs it, I have made a function that takes care of all the steps including adding it to the logical switch as a virtual port:

Screen Shot 2015-01-19 at 11.54.28

And also a function for removing, in this I check the VM´s connected and moving them to the default port profile before removing it,

Screen Shot 2015-01-19 at 11.55.18

Probably there will be some updates to this in the future but here you can see and test for your own needs 🙂  I will now start to test some bandwidth flooding to see that it actually limits the VM´s