I am not familiar with the VCD cmdlets at all, but I can provide maybe a couple of tips in general that could help.
The one thing you may want to take a look at though is the number of "Get" commands you are running.... Namely that you are doing a Get-CINetworkAdapter for each and every $vm and a Get-CIVM for every vapp... that is probably where most of your slowness is coming from....
It would be must faster to do those Gets before the FOREach statements, and then just do a filter, or a where-object in the foreach...
I hope this helps