Bring a medium pot of salted water to a boil. Add the trimmed green beans and cook for 4-5 minutes until bright green and crisp-tender. Drain in a colander and set aside.
In a skillet, melt the butter over medium heat. Once melted, whisk in the flour and cook for about 1 minute until the mixture is bubbly.
Gradually add the milk, stirring continuously until the mixture thickens, about 2-3 minutes.
Stir in the garlic powder, onion powder, and salt and pepper to taste. Remove the skillet from heat and mix in the shredded cheddar cheese until melted and well combined.
In a large mixing bowl, combine the cooked green beans with the cheese sauce. Stir until the beans are well coated.
Pour the cheesy green beans into a greased 9x13 inch baking dish. If desired, sprinkle the grated Parmesan cheese on top.
Preheat your oven to 350°F (175°C). Bake the dish in the preheated oven for 15-20 minutes until bubbly and golden on top.
Remove from the oven, let cool slightly, and serve warm.