Preheat the oven to 400°F. Grease a 9x13-inch baking dish with butter or nonstick cooking spray.
Heat oil in a medium saucepan over medium heat. Add diced onion and cook until translucent.
Sprinkle flour over the onion and stir. Gradually add half-and-half and broth, stirring constantly. Season with salt, pepper, and garlic powder. Heat until slightly thickened.
Layer the diced potatoes evenly in the prepared baking dish. Add the diced ham on top.
Pour the thickened mixture of onion and half-and-half over the ham and potatoes.
Cover the dish and bake for 45 minutes. Take it out of the oven, add shredded cheese on top, and then return it uncovered.
Bake for another 15 minutes, or until the cheese melts and the potatoes are tender.