When trying to set the connected property of a network card within virtual machine you receive:
Get-VM -name XYZ | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$true Set-NetworkAdapter : 7/6/2012 10:59:14 AM Set-NetworkAdapter The operation for the entity VirtualMachine-vm-777 failed with the following message: " Invalid configuration for device '0'."
If you use vCenter Server 5.0, vCenter Server 5.0 Update 1, ESXi 5.0, and ESXi 5.0 Update 1. then you could be probably affected by this problem described here
What will happen :
You will notice that your vm nics are not “connected” although they have setting “connect at power on” checked.
If you will try to check the “connected” property you will receive error “Invalid configuration for device ‘0’
There is no way to fix this issue on a permanent basis. All you can do now is to proceed with vmware KB 2013639 in order to fix your vms. There is a powercli script attached in the KB, download it and execute it:
# Get-VM | Test-VDSVMIssue This will show you which vm is affected # Get-vm | Test-VDSVMIssue -fix This will try to fix issue for all your vms
If you want to test it first for a particular vm select one using :
get-vm -name "your vm" | Test-VDSVMIssue -fix
What happens is that if your vm is affected by this issue, it looses information about its vmnic portid in the vmnic portgroup.
The script provided by vmware fixes this by changing the portid for this vmnic and then reverting the portid to the old portid.
You can check it manually if you are affected by doing following steps:
Open vSphere client , switch to networking view, and select the portgroup where your vm has vmnics attached.
Open your vm vmx file to check which portid was configured. You can read the vmx file using ssh to esxi host or download the vmx file using datastore browser within vSphere client.
When your vm vmnic is using distributed vswitch you will see entries like those:
ethernet0.dvs.switchId = "8d 7e 0b 50 67 e4 0b 46-3f 30 0b f8 d5 6a 58 f3" ethernet0.dvs.portId = "1234"
In case you are affected, you will notice that although you can see that this vmnic is using this portid(verified by checking portgroup in vSphere client) there is no file on datastore
in vds directory ‘.dvsData/ethernet0.dvs.switchId’ where ethernet0.dvs.switchId should be changed to your switch id
That’s why we can not change the state of vmnic to connected.
Run the vmware powercli script from KB, it should tell you that problem was fixed.
If you will now check the .dvsData/switchID directory you should find a file with name of the portID that was choosen for this vmnic
From that moment go to vm and select “connected” property to on. You should not see the Invalid configuration for device ‘0’ error again.
You can experience this problem even if your vms are not using sdrs.
If you have large amount of vms that are affected by this and you want to automate process of selecting “connected”, you can automate checking the ‘connect’ box property using :
get-vm -Name AffectedVM | Get-NetworkAdapter | select connectionstate #check if it is disconnected, after the applying the fix for this vm use get-vm -Name AffectedVM | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$true -Confirm:$false #this will enable the 'connected' property
if you have more than 1 vm for which you want to edit this property you can list them in this one command
get-vm -Name AffectedVM,AffectedVM2,AffectedVM3 | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$true -Confirm:$false