Position an oven rack in the middle of the oven and preheat to 375 degrees F. Lightly butter a 9-by-13-inch metal baking pan.
Whisk together the half-and-half, vanilla, 4 eggs, 1 teaspoon salt and 1/2 teaspoon pepper in a large mixing bowl.
Lay 7 slices of bread in a single layer on a cutting board. Sprinkle 2 heaping tablespoons Gruyere on top of each slice. Top each with 2 slices of ham, folding the ham as needed to fit. Place the remaining 7 slices bread on top to form 7 sandwiches. Cut each sandwich in half diagonally. Dip both sides of each sandwich half into the custard mixture and transfer to the prepared baking pan, arranging in 2 long shingled rows. Pour any remaining custard over the sandwiches and sprinkle the remaining Gruyere on top.
Spray a large piece of foil with nonstick spray. Place the foil sprayed-side down on top of the baking pan, crimping the sides of the foil around the pan to seal. Bake for 30 minutes. Remove the foil and bake until the custard is set but still slightly jiggly, about 10 minutes more. Switch the oven to broil and broil until the top is light golden brown, another 3 to 5 minutes. Allow to rest for 5 minutes.
Meanwhile, heat the butter in a large nonstick pan over medium heat. Crack 3 eggs into the pan (it's okay if they run together) and lightly sprinkle with salt. Cook until the whites start to set, 1 to 2 minutes, then cover and continue cooking until the whites are set but the yolks are still runny, 1 to 2 minutes. Transfer to a plate and repeat with the remaining 3 eggs.
Divide the casserole among 6 plates, dust with confectioners' sugar, top with the maple syrup or jam if using and finish with a fried egg on top.
Copyright 2019 Television Food Network, G.P. All rights reserved.