Preheat the oven to 350 degrees F. Add the butter to a large heavy skillet. Once foaming and melted, add the garlic, ham, onions and some salt and pepper. Saute until the onions are tender and the ham is browned, about 4 minutes. Stir in the flour and cook until pasty, about 2 minutes. Add the milk and stock and stir until smooth. The mixture will begin to thicken as it comes to a simmer. Once thick, turn off the heat and add 1 cup of the shredded cheese. Stir until melted. Add the hash browns and green onions and stir until well mixed. Add to a 13-by-9-inch casserole dish and sprinkle with the remaining 1/2 cup cheese. Bake until the top is golden and the potatoes are tender, 45 minutes.