Preheat the oven to 350 degrees F. Spray a 9x13-inch baking dish with non-stick cooking spray, set aside.
Slice the potatoes 1/8th of an inch thick (we like to use a mandolin for this) and place them into a large bowl with cold water, set aside.
In a large skillet over medium-low heat, melt the butter. Add the onion and cook until softened, stirring occasionally, 5-8 minutes. Add the garlic and cook for 30 seconds until fragrant, stirring constantly.
Add the flour to the pan, stir it in to combine, it will form a paste. Cook for 2 minutes stirring constantly. Slowly stream in the milk and heavy cream while stirring constantly to make sure there are no lumps. Add salt and pepper, cook until thickened, 2-3 minutes, stirring occasionally.
Take off the heat and stir in half of the cheese until melted, set aside.
Layer half of the sliced potatoes into the bottom of the baking dish. Add half of the cooked ham on top. Ladle half of the cheese sauce on top. Repeat. Cover with foil and bake for 60 minutes.
Remove the foil, bake for an additional 15 minutes. Top with the remaining cheese and bake for an additional 15 minutes or until the potatoes are tender all the way through. Let sit for about 15 minutes before serving. Serve with a garnish of fresh chopped parsley, optional.