Skip navigation

Q. I'm using System Center Virtual Machine Manager (SCVMM). How can I delete an emulated NIC from a virtual machine (VM) within a script?

A. I recently had a situation where a VM was auto-provisioned using a boot from network. To boot over the network, a Hyper-V VM must use an emulated NIC, but once the VM was provisioned, I needed to remove the emulated NIC in favor of the much better performing synthetic NIC.

The script below removes all emulated NICs from a passed VM. Save this as removevmlegacyNIC.ps1 and replace the name of the VMMServer with your SCVMM Server.

 

# Connect to the VMM server.
$VMMServer = Get-VMMServer -ComputerName "savdalvmm01.savilltech.net"

# Ensure that the virtual machine is stopped.
If ($args\\[0\\].StatusString -ne "Stopped")
\\{
Stop-VM -VM $args\\[0\\]
\\}
get-vm $args\\[0\\] |select -ExpandProperty VirtualNetworkAdapters | where \\{$_.VirtualNetworkAdapterType -eq "Emulated"\\} | Remove-VirtualNetworkAdapter

 

To use it, just run the following from a SCVMM PowerShell prompt:

 

.\removevmlegacyNIC.ps1 savdalclient2

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish