Melt 4 Tablespoons butter in a medium saucepan. Add the flour, whisk to combine thoroughly. Cook the mixture until it bubbles, after it bubbles, let it cook one more minute to eliminate the flour taste. Slowly whisk 3 cups of milk into the pot. Add the salt , pepper and garlic powder.. Cook 3 - 4 minutes until the mixture thickens. Remove from the heat and set aside.
Combine the potatoes,onion and ham cubes in a large bowl, toss gently to combine. Oil an 9x13 inch baking dish. Place half the potato mixture into the pan, pour half the sauce over the potatoes evenly. Layer the remaining potato mixture over the sauce and top with the remaining sauce. Dot the casserole with the remaining 4 Tablespoons of butter cut into cubes. Bake at 375 degrees covered with foil for 60 minutes. Uncover the casserole and bake an additional 20 minutes until the casserole is bubbly and potatoes are fork tender. Serve immediately.