Skip to content

Instantly share code, notes, and snippets.

@gowatana
Created May 13, 2021 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/140471de75d2c2867a9e5e0377c628b3 to your computer and use it in GitHub Desktop.
Save gowatana/140471de75d2c2867a9e5e0377c628b3 to your computer and use it in GitHub Desktop.
$ESX = "192.168.10.164" # または esxi01.example.com
$VDS = "VDS_A"
$VMNIC1 = "vmnic1"
$VMNIC2 = "vmnic2"
$UPLINK1 = "UpLink_1"
$UPLINK2 = "UpLink_2"
$UPLINK_PG = "UpLinkPG_A"
$PG = "PG_A"
# ①VDS_Aへ新規ホストを追加
Get-VDSwitch -Name $VDS | Add-VDSwitchVMHost -VMHost $ESX
# ②vmnic1のアップリンク設定
$vmHostNetworkAdapter = Get-VMHost -Name $ESX | Get-VMHostNetworkAdapter -Physical -Name $VMNIC1
Add-VDSwitchPhysicalNetworkAdapter -DistributedSwitch $VDS -VMHostPhysicalNic $vmHostNetworkAdapter -Confirm:$false
Get-VDSwitch -VMHost $ESX -Name $VDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort $UPLINK1
# ③vmnic2のアップリンク設定
$vmHostNetworkAdapter = Get-VMHost -Name $ESX | Get-VMHostNetworkAdapter -Physical -Name $VMNIC2
Add-VDSwitchPhysicalNetworkAdapter -DistributedSwitch $VDS -VMHostPhysicalNic $vmHostNetworkAdapter -Confirm:$false
Get-VDSwitch -VMHost $ESX -Name $VDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort $UPLINK2
# ④vmk0の移行
Get-VMHost $ESX | Get-VMHostNetworkAdapter -Name vmk0 | Set-VMHostNetworkAdapter -PortGroup $PG -Confirm:$false