Preheat your oven to 400 °F. Grease a 2 quart casserole dish with butter and set aside.
In a medium sized sauce pan, melt the butter over medium-high heat. Add in the grated onions and cook until tender and soft.
Add in the flour and stir until mixed throughout the butter. Stir for another minute, then whisk in the milk slowly, stirring with the whisk to ensure that there are no lumps. Add in the cream.
Season with the salt to your own taste (start at 1/2 tsp) followed by the garlic powder.
Cook the sauce on low until smooth and thick, stirring occasionally with the whisk to ensure that the mixture doesn't burn on the bottom of the pot.
Reduce the heat and stir in the cheese, whisking until it is smooth. Taste, and if needed, add more cheese to your liking. ( some people like a more "milky" sauce than a cheesy one.)
Place a third of the sliced potatoes in the casserole dish.
Pour a third of the cheese sauce over the first layer of sliced potatoes. Sprinkle 1/3 of the ham on top.Repeat with the remaining layers of potatoes and cheese sauce.
Bake covered in the oven for 30 minutes.
Take off the lid and sprinkle the remaining cheese on top and paprika if wanted.
Bake uncovered for another 30 minutes, or until the potatoes are tender and cooked.
Scalloped potatoes are notorious for taking a long time to bake. If the cheese is getting too browned on top at the end and the potatoes are still hard, cover it and bake until the potatoes are tender.