替换e1000网卡适配器为Vmxnet3的脚本

e1000系网卡的vm容易导致RX ring缓存溢出而造成主机紫屏的问题,目前的解决办法就是修改网卡适配器的类型为Vmxnet3
但是在viclient界面中发现不能编辑网卡适配器类型,只能重新添加,比较麻烦。
因此提供如下powercli脚本解决以上问题:
脚本可以替换关机或正在运行的vm的网卡类型,支持多网卡适配器,
支持模糊匹配(如虚拟机有Win7-1、Win7-2…,修改MyVM1名称为 Win7-*  即可,一次性替换所有名称以 Win7- 开头的虚拟机网络适配器类型)

Connect-VIServer -Server serverip -username root -Password passw0rd
Get-VM MyVM1 | Get-NetworkAdapter | Where {$_.Type -eq “E1000”} | Set-NetworkAdapter -Type vmxnet3

注意:需要替换以上vc server的ip地址 和 修改相应的密码, 并 替换 MyVM1为你实际虚拟机的名称

脚本可以实现批量替换所有的虚拟机,但是考虑到并不是所有vm都安装了vmtools,所以酌情考虑自行修改代码。
有文章提示脚本修改vm的网络适配器类型后需要关机,然后启动该vm配置才有效。

另外一种办法:编辑.vmx 配置文件
You can change the adapter type by editing the virtual machine configuration file. This can be done by connection the the ESXi host with SSH or by simply downloading, changing and uploading the configuration file. Steps:

Power off the virtual machine
Remove the virtual machine from inventory
Change ethernetX.virtualDev parameter in the the .vmx File
Register the virtual machine
Power on the virtual machine

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注