#批量添加交换机 foreach ($vmhost in $(get-vmhost)) { New-VirtualSwitch -VMHost $vmhost -Name VSwitch -nic nic1,nic2 } #给交换机批量添加端口组 foreach ($vmhost in $(get-vmhost)) { $vswitch = Get-VirtualSwitch -VMHost $vmhost -Name vSwitch0 $vportgroup = New-VirtualPortGroup -VirtualSwitch $vswitch -Name Default0 } #端口组批量添加虚拟机 foreach ($vm in $(get-vm )){ Get-NetworkAdapter -vm $vm | Set-NetworkAdapter -NetworkName Default0 -Confirm:$false -RunAsync }
本文出自 “汜水流年_” 博客,请务必保留此出处http://timefiles.blog.51cto.com/8475652/1959282
原文地址:http://timefiles.blog.51cto.com/8475652/1959282