Preheat the oven to 350° F. Grease an 8-by-8-inch baking dish with cooking spray or vegetable oil.
In a skillet over medium heat, melt butter. Add the onions and saute until translucent, 3 to 4 minutes. Add flour and stir until combined. Cook 1 to 2 minutes. Add garlic, salt, pepper, cayenne and ground mustard. Whisk in the milk. Allow to cook and thicken slightly, about 3 minutes. Remove the pan from the heat.
Line the baking dish with a layer of the ham, then a layer of slightly overlapping potatoes, then about 2/3 cup sauce. Repeat the layering until all the ingredients are used, making 3 layers, ending with the sauce on top. Top with cheese and cover with foil. Bake until potatoes are tender, about 1 hour.
Remove the foil and switch on broiler. Broil until the cheese is bubbly and browned, about 3 minutes. Watch carefully to not allow it to burn . Garnish with parsley and allow to cool slightly before serving..
1. 2% milk was used for this recipe. 2. Melting cheese like Swiss or Gruyere can be substituted for the Monterey Jack. 3. For less heat, reduce the cayenne pepper to 1/4 teaspoonIf using salted butter, omit adding salt to recipe and salt to taste before serving.