#批量添加交换机 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 }
时间: 2024-08-05 17:38:26