29 Jan 2013 @ 8:29 AM 

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

Set-VMNetworkAdapter –VMName MyVM –PortMirroring Source

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 ;-)

$VM = Get-VMNetworkAdapter -VMName MyVM
$VM[1] | Set-VMNetworkAdapter –PortMirroring Source

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.

Post to Twitter

Posted By: Jeff Wouters
Last Edit: 29 Jan 2013 @ 08:29 AM

EmailPermalink
Tags
Categories: DuPSUG, Hyper-V, PowerShell



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 251
  • Comments » 430
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.