VMware Cloud Community
AntonVZhbankov
Immortal
Immortal

Problem with empty network name

I have a couple of VM replicas on ESXes where network name doesn't match - source and destination ESXes are parts of different distributed vSwitches.

I wanted to change it via script, but got such message:

Get-NetworkAdapter : 22.07.2010 13:24:29    Get-NetworkAdapter        Value cannot be null.
Parameter name: key
At line:1 char:38
+ get-vm *_replica | Get-NetworkAdapter <<<<  | Set-NetworkAdapter -NetworkName "VM Network"
    + CategoryInfo          : NotSpecified: (:) [Get-NetworkAdapter], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.
   GetNetworkAdapter

And of course nothing changed for that VMs.

Since it is related to replicas, I can not change it by hands once. Have I any opportunity except moving destination ESXes to the same dvSwitch or moving all my ESXes back to standard vSwitches?


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

Are you sure you are using PowerCLI 4.1 ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AntonVZhbankov
Immortal
Immortal

Yes. PowerCLI, vCenter and both source and destination hosts are 4.1


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos
LucD
Leadership
Leadership

And do you see the network name in the vSphere client ?

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
AntonVZhbankov
Immortal
Immortal

Nope. Empty box.


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos
ykalchev
VMware Employee
VMware Employee

Can you please post the exception details so we can try to guess what goes wrong?

$error[0].Exception | select *
$error[0].Exception.InnerException | select *

Thanks,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team
Reply
0 Kudos
AntonVZhbankov
Immortal
Immortal

Strange situation, look like it happens with dvSwitch only, and not with standard vSwitch.

I'll check twice and post what I've found.


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos
AntonVZhbankov
Immortal
Immortal

It happens when destination host has no standard vSwitch.

[vSphere PowerCLI] C:\> get-vm "New Virtual Machine_replica" | Get-NetworkAdapter
Get-NetworkAdapter : 23.07.2010 12:54:58    Get-NetworkAdapter        Value cannot be null.
Parameter name: key
At line:1 char:58
+ get-vm "New Virtual Machine_replica" | Get-NetworkAdapter <<<<
    + CategoryInfo          : NotSpecified: (:) [Get-NetworkAdapter], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.
   GetNetworkAdapter

[vSphere PowerCLI] C:\> $error[0].Exception | select *


ErrorId           : Core_BaseCmdlet_UnknownError
ErrorCategory     : NotSpecified
TargetObject      :
RecommendedAction :
SessionId         :
ConnectionId      : /VIServer=@vcenter:443/
Severity          : Error
Message           : 23.07.2010 12:54:58    Get-NetworkAdapter        Value cannot be null.
                    Parameter name: key
Data              : {ParameterValues}
InnerException    : System.ArgumentNullException: Value cannot be null.
                    Parameter name: key
                       at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                       at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                       at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
                       at VMware.VimAutomation.ViCore.Impl.V1.VirtualDevice.NetworkAdapterImpl..ctor(VirtualEthernetCard nic, Dictionary`2 dvPortgrou
                    pList, String parentId, VimClient client)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.CreateVirtualDevice(VirtualDevice device, String paren
                    tId, Dictionary`2 dvPortgroupList, VimClient client)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualDevice[T](IEnumerable`1 contentList, Diction
                    ary`2 dvPortgroupList, IEnumerable`1 dnFilterList)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualDevice[T](IEnumerable`1 parentUidList, IEnum
                    erable`1 dnFilterList)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualNetworkAdapter(IEnumerable`1 parentUidList,
                    IEnumerable`1 dnFilterList)
                       at VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetNetworkAdapter.DoWork(VIAutomation client, List`1 moList)
TargetSite        :
StackTrace        :
HelpLink          :
Source            :

[vSphere PowerCLI] C:\> $error[0].Exception.InnerException | select *


Message        : Value cannot be null.
                 Parameter name: key
ParamName      : key
Data           : {}
InnerException :
TargetSite     : Void ThrowArgumentNullException(System.ExceptionArgument)
StackTrace     :    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
                    at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
                    at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
                    at VMware.VimAutomation.ViCore.Impl.V1.VirtualDevice.NetworkAdapterImpl..ctor(VirtualEthernetCard nic, Dictionary`2 dvPortgroupLi
                 st, String parentId, VimClient client)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.CreateVirtualDevice(VirtualDevice device, String parentId
                 , Dictionary`2 dvPortgroupList, VimClient client)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualDevice[T](IEnumerable`1 contentList, Dictionary
                 `2 dvPortgroupList, IEnumerable`1 dnFilterList)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualDevice[T](IEnumerable`1 parentUidList, IEnumera
                 ble`1 dnFilterList)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.VirtualDeviceServiceImpl.GetVirtualNetworkAdapter(IEnumerable`1 parentUidList, IEn
                 umerable`1 dnFilterList)
                    at VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.GetNetworkAdapter.DoWork(VIAutomation client, List`1 moList)
HelpLink       :
Source         : mscorlib


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos
ykalchev
VMware Employee
VMware Employee

Hi,

Thanks for the details it helps me a lot.

It seems that replicaVMs has empty record for vDS portgroup details in your case which makes Get-NetworkAdapter to report this error.

You can use Get-View cmdlet and this script to update NetworkName of those VMs:

$vm = Get-VM myVM | Get-View 
$networkCard = $vm.Config.Hardware.Device | ? {$_ -is [http://VMware.Vim.VirtualEthernetCard|http://VMware.Vim.VirtualEthernetCard] }
$vDSPortGroupName = "dvPortGroup"

$vDSPortGroup = Get-View -ViewType DistributedVirtualPortgroup -Filter @{"Config.Name"=$vDSPortGroupName}
$vDS = Get-View $vDSPortGroup.Config.DistributedVirtualSwitch

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.deviceChange = New-Object VMware.Vim.VirtualDeviceConfigSpec[] (1)
$spec.deviceChange[0] = New-Object VMware.Vim.VirtualDeviceConfigSpec
$spec.deviceChange[0].operation = "edit"
$spec.deviceChange[0].device = $networkCard
$spec.deviceChange[0].device.backing.port = New-Object VMware.Vim.DistributedVirtualSwitchPortConnection
$spec.deviceChange[0].device.backing.port.switchUuid = $vDS.Uuid
$spec.deviceChange[0].device.backing.port.portgroupKey = $vDSPortGroup.Key

$vm.ReconfigVM($spec)

 

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team
Reply
0 Kudos
AntonVZhbankov
Immortal
Immortal

I moved back to standard vSwitches already, Veeam Backup lacks ability to connect replica VM to another portgroup, and this can lead us to some problems in emergency situation.

What I want to see - fix for this in nearest builds.


---

MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert

http://blog.vadmin.ru

EMCCAe, HPE ASE, MCITP: SA+VA, VCP 3/4/5, VMware vExpert XO (14 stars)
VMUG Russia Leader
http://t.me/beerpanda
Reply
0 Kudos