You can have a look at my VMX Raiders Revisited to find orphaned VMs.
But looking at the code you included, I'm not sure what exactly you are looking for.
The general consensus on orphaned VMs is that they are VMs that still live on storage, but aren't registered to any vCenter anymore.
Perhaps you can explain a bit more what you consider orphaned VMs.
in that list, i am trying to include
1. the vms not registered
2. the vms network disconnction
No, it will not delete the orphaned VMs, but it will try to register them.
You can comment out the registration part.
If you also use the WhatIf switch you will only get the results, no registration will happen.
Not sure how you want to get the network connection on unregistered VMs?