Preheat oven to 375°F and grease a 9x13-inch baking dish.
Cook macaroni according to package directions until al dente, drain and set aside.
In a large pot, melt 4 tablespoons butter over medium heat, then whisk in flour and cook for 1 minute until golden.
Gradually whisk in milk and cook, stirring constantly, until sauce thickens, about 5 minutes.
Remove from heat and stir in cheddar and Gruyère until melted and smooth.
Add garlic powder, salt, and pepper, then fold in cooked macaroni and diced ham.
Pour mixture into prepared baking dish and spread evenly.
Combine panko breadcrumbs with melted butter and sprinkle over the top.
Bake for 25-30 minutes until bubbly and golden brown on top, then let rest 5 minutes before serving.