VMware Cloud Community
NordalLund
Contributor
Contributor

Finding VM name and invalid Port IDs on Virtual Portgroups

Hi all,

We have an issue where restored VM's get an invalid Port ID in the virtual portgroup. The VM is connected to the network, and at first glance working as expected. But when trying to migrate the VM, we will get an error (vim.fault.notfound)

The solution is to change the port id to a valid one. Usually the invalid Port ID will begin with "c-" so the c dash will indicate we have an invalid Port ID and we need to fix it. 

I am trying to create a script to locate VM's with a Port ID starting with "c-" but until now i havent been able to extract the Port ID value with powercli. Maybe someone in here are able to help?

FYI, the restores are donw with CommValut, maybe some of you have experienced the same issue?

Best Regards, Kasper 

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

Yes, I have seen the same with CV restores.

The restored VM tries to connect to the original port, which might have been taken in the mean time (since the backup).

But I'm not sure how the c- prefix fits in there.

Could you perhaps share a screenshot of a VM with the issue, and where this c- prefix is displayed?


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

Reply
0 Kudos
sarikrizvi
Enthusiast
Enthusiast

Check this KB # 2014469 - VMware Knowledge Base and I believe it will solve the problem

or try this PowerCLI script if it helps to identify VMs which were have error Invalid or inaccessible

Get-View -ViewType VirtualMachine | Where {-not $_.Config.Template} | Where{$_.Runtime.ConnectionState -eq “invalid” -or $_.Runtime.ConnectionState -eq “inaccessible”} | Select Name





Regards,
SARIK (Infrastructure Architect)
vExpert 2018-2020 | vExpert - Pro | NSX | Security
vCAP-DCD 6.5 | vCP-DCV 5.0 | 5.5 | 6.0 | vCA-DCV 5 | vCA-Cloud 5 | RHCSA & RHCE 6 | A+ (HW & NW)
__________________
Please Mark "Helpful" or "Correct" if It'll help you
_____________________________________
@Follow:
Blog# https://vmwarevtech.com
vExpert# https://vexpert.vmware.com/directory/1997
Badge# https://www.youracclaim.com/users/sarik
Reply
0 Kudos
NordalLund
Contributor
Contributor

Heres a screenshot.

The VM has two nics, both have Port ID's that are invalid and starting with c-

/Kasper

Reply
0 Kudos
LucD
Leadership
Leadership

Does the following also show the c-prefix?

Use the name of a VM that has the issue.

Get-VM <VM-with-error> |

Get-NetworkAdapter |

Select Name,@{N='PortKey';E={$_.ExtensionData.Backing.Port.PortKey}}


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

Reply
0 Kudos
NordalLund
Contributor
Contributor

That did the trick, thanks LucD.

I have been traversing through almost all other objects in extensiondata with no luck.

Great 🙂

BTW. I have made a request to our backup dept. to investigate if they are able to prevent this when doing restores. I think the issue is that we do not delete the original VM, and this is holding the Port ID, but giving it this invalid ID is not a nice solution.

Reply
0 Kudos
NordalLund
Contributor
Contributor

If anyone is curious, i ended up with this:

 

get-vm | where {($_ | Get-NetworkAdapter).ExtensionData.backing.port.portkey -like "c-*"} | select Name,PowerState,@{N="Port ID";E={($_ | Get-NetworkAdapter).ExtensionData.backing.port.portkey}}

 

/Kasper

PS D:\Users\z8qno> get-vm | where {($_ | Get-NetworkAdapter).ExtensionData.backing.port.portkey -like "c-*"} | select Name,PowerState,@{N="Port ID";E={($_ | Get-NetworkAdapter).Ext
ensionData.backing.port.portkey}}
Reply
0 Kudos
LucD
Leadership
Leadership

That would make a nice vCheck plugin :smileygrin:


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

Reply
0 Kudos