Preheat oven to 375°F. Grease a 9x9-inch baking dish with butter or cooking spray.
In a medium saucepan over medium heat, melt butter. Whisk in flour and cook for 1–2 minutes to form a roux.
Slowly whisk in milk, stirring constantly until the sauce thickens (about 4–5 minutes).
Stir in cheddar cheese, garlic powder, onion powder, salt, and pepper. Remove from heat once cheese is melted and sauce is smooth.
Arrange half of the sliced potatoes in the baking dish. Pour half of the cheese sauce over the potatoes.
Layer the remaining potatoes on top and pour the rest of the cheese sauce evenly over them.
Sprinkle Parmesan cheese on top if using.
Cover with foil and bake for 40 minutes.
Remove foil and bake for another 20–25 minutes until the top is golden and bubbly and potatoes are fork-tender.
Let sit for 10 minutes before serving.
Prep Time: 15 minutes | Cooking Time: 1 hour 5 minutes | Total Time: 1 hour 20 minutes
Kcal: Approx. 310 per serving | Servings: 6