Preheat the oven to 375°F (190°C).
Grease a baking dish with butter.
Layer half of the sliced potatoes at the bottom of the dish.
Sprinkle half of the diced ham over the potatoes.
In a bowl, mix the cream, garlic, salt, pepper, and thyme.
Pour half of the cream mixture over the first layer.
Repeat the layers with the remaining potatoes and ham.
Pour the remaining cream mixture on top.
Cover the dish with aluminum foil and bake for 45 minutes.
Remove the foil, sprinkle cheese on top, and bake for an additional 15 minutes until golden.