What is the best way to add VMkernel virtual adapters when migrating a host using VDS from vCenter1 to vCenter2? I've attached a sample script I'm using for the process. The last Add-VDSwitchPhysicalNetworkAdapter command fails with a "Value cannot be null" error.
For background, I have a source vCenter Server (version 5.0) and a target vCenter Server (version 5.5). I would like to do a hot migration of a host that uses VDS from vCenter1 to vCenter2. If I run the script step by step, everything works as expected until the Add-VDSwitchPhysicalNetworkAdapter command. I can then complete the process manually using the following process in the vSphere Client:
Hosts and Clusters -> Select host -> Configuration -> Networking -> vSphere Distributed Switch -> Manage Virtual Adapters (for the appropriate VDS) -> Add -> Migrate existing virtual adapters
After completing the manual steps above, I can then remap the VMs and then remove the old VDS (which no longer exists).
Something like this
$vdpgNames = 'Management Network', 'Storage Network', 'vMotion Network'
$vdpg = Get-VDPortgroup -Name $vdpgNames -VDSwitch $TargetVDS
Add-VDSwitchPhysicalNetworkAdapter -DistributedSwitch $TargetVDS -VMHostPhysicalNic $vmhostNetworkAdapter -VirtualNicPortgroup $vdpg -VMHostVirtualNic $vmk0, $vmk1, $vmk2 -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
On the VirtualNicPortgroup parameter, did you already try passing VDPortgroup objects instead of the names ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, I haven't done that. Can you please show me what that would look like?
Something like this
$vdpgNames = 'Management Network', 'Storage Network', 'vMotion Network'
$vdpg = Get-VDPortgroup -Name $vdpgNames -VDSwitch $TargetVDS
Add-VDSwitchPhysicalNetworkAdapter -DistributedSwitch $TargetVDS -VMHostPhysicalNic $vmhostNetworkAdapter -VirtualNicPortgroup $vdpg -VMHostVirtualNic $vmk0, $vmk1, $vmk2 -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That did it. Thanks for your help!