In a 10- to 12-inch frying pan, combine oil, onion, garlic, and mushrooms. Stir often over high heat until onion is limp, 3 to 4 minutes.
Add ham and stir often until mushrooms are lightly browned, about 5 minutes longer.
Add tomato sauce and pesto to mushroom mixture. Turn heat down to low.
Squeeze liquid from spinach. Add spinach to pan and heat until simmering.
Meanwhile, cook vermicelli in about 3 quarts boiling water until just tender to bite, 7 to 9 minutes. Drain and keep warm.
Mix yogurt and cornstarch. Stir into sauce, then stir over high heat until bubbling, about 3 minutes.
Pour sauce over pasta. Mix to blend. Add salt and pepper to taste.