Peel and thinly slice the potatoes to ¼ inch thick or thinner.
Place the potatoes in a bowl and cover with ice water. Place in the refrigerator and soak for 4 hours, then rinse under cold water in a colander.
In a sauce pan, melt the butter over medium heat. Add the garlic and cook for 1 minute. Next, stir in the flour and whisk to combine, mixing until fully incorporated. Add the heavy cream to the pan about ½ cup at a time, whisking continuously until thickened before adding more cream.
Once all of the heavy cream has been added, add it the garlic powder, onion powder, salt, black pepper, and thyme leaves.
Next, add in the shredded cheese a little at a time and stir until melted before adding more cheese. Reserve ½ cup of cheese for topping. Once all of the cheese has been added and the sauce is smooth, remove the pan from the heat and set aside.
Grease the bottom and sides of a cast iron pan or skillet with butter or oil. Place a single layer of potato slices over the bottom on the pan, then layer about ⅓ of the sliced onions. Next pour about ¼ of the cheese sauce over the potatoes.
Repeat with 2 more layers of potatoes, onion and cheese sauce then finish with a final layer of potatoes. Top with the last of the cheese sauce and then the ½ cup of shredded cheese. If desired sprinkle with additional thyme.
Preheat your grill or smoker to 350 degrees and set up for indirect heat.
Place the cast iron pan with the au gratin potatoes on the smoker and cook for 1.5 hours, checking about every 30 minutes and rotating if needed for even cooking.
The smoked au gratin potatoes are done when the top is golden brown, and you can poke the potatoes with a toothpick and there is very little resistance. If the cheese is getting too dark before the potatoes are tender, cover the pan with foil to prevent further browning.
Serve while warm.