Cook Spaghetti noodles according to package directions. Drain and set aside.
Add 2 tablespoons butter to a saute pan. Add mushrooms. Cook until browned. Remove from pan. Do not wipe or rinse pan.
With same pan add 4 more tablespoons butter. When melted, add flour. Stir over medium low heat for 2-3 minutes.
Slowly add milk while whisking flour mixture. Continue whisking until mixture begins to thicken.
Add chicken stock and combine.
Add nutmeg, thyme and pepper. Continue cooking over medium heat until mixture is heated through.
Stir in sherry (if using) and add mushrooms and ham.
Taste mixture. Add salt if needed.
Combine mixture with spaghetti noodles and then place into a lightly greased casserole dish.
Top with Parmesan cheese
Bake in a preheated 400 degree oven for 25-30 minutes until mixture is bubbly and top is golden.
Remove from oven and let rest for 10 minutes before serving.