Hello, TdisalvoOrinoco-
Interesting indeed. It appears that the Guest.Nics property of a VM with a NIC on a dvSwitch does not get the NetworkName property updated after changing the network adapter to use a dvSwitch portgroup from a portgroup on a standard vSwitch.
So, for now, I updated the code above to use a slightly different route to get the NetworkName info -- accessing the NetworkAdapters property of the VM. This works alright, but this NetworkAdapters property is deprecated, so it may (will) go away someday when VMware sees fit. Hopefully, though, VMware will address the non-populated/updated NetworkName property of the Guest.Nics items (assuming other people are seeing this same behavior), so we won't have to use the deprecated property (or get all serious with some Get-View action).
Anyway, does that updated code do better for you?