Preheat your oven to 350°F (175°C). Grease a 9x13-inch baking dish with butter or cooking spray.
In a large saucepan over medium heat, melt the butter. Stir in the flour, garlic powder, onion powder, salt, pepper, paprika, and thyme. Cook for about 1 minute, stirring constantly.
Gradually whisk in the milk and heavy cream. Continue to cook, stirring frequently, until the mixture thickens and bubbles, about 5-7 minutes.
Layer half of the sliced potatoes in the prepared baking dish. Pour half of the cream sauce over the potatoes, then sprinkle half of the diced ham and half of the cheese on top. Repeat with the remaining potatoes, sauce, ham, and cheese.
Cover the baking dish with aluminum foil and bake for 45 minutes. Remove the foil and bake for an additional 15-20 minutes, or until the potatoes are tender and the top is golden brown and bubbly.
Let the dish cool for about 10 minutes before serving to allow the sauce to thicken.