PowerShell – Configure port mirroring in Hyper-V

Earlier this week I’ve received a question about selecting the correct VM network adapter to configure port mirroring on.

Now this command will confire port mirroring alright, but for all the network adapters attached to the VM.
What if you have multiple netwerk adapters attached?

If you were to do a Get-VMNetworkAdapter you’ll notice that all the network adapters have the same name.
Yes, you can do some filtering to eventually only get the one you want… but maybe there’s an easier way…

Now let’s assume that you’ve automated your environment and that your VMs are consistent in their configuration.
In that case, you can assume that if there are three network adapters attached, the 2nd network adapter will be the same on all VMs.
We can work with that 😉

As you may have noticed I’m selecting the 1th NIC, right? Wrong 😉
That’s the little gotcha when working with arrays… they start the count at 0 (zero). So in fact I’m selecting the 2nd NIC.

Leave a Reply

Your email address will not be published. Required fields are marked *