Preheat oven to 350 degrees F°. Spray a 9×13-inch baking dish with cooking spray.
In a large bowl, mix together cream of mushroom soups, sour cream, onion and 1 ½ cups of the shredded cheese. Mix together well. Season with salt and pepper.
Add in frozen hash browns, and chopped ham (if using) and mix all together well. Pour mixture into the prepared baking dish; spreading out evenly.
Bake uncovered, for 45 minutes.
While potatoes are baking, mix together the crushed corn flakes, melted butter and the last 1/2 cup of shredded cheese.
When potatoes are done cooking, remove from oven and sprinkle the top evenly with the corn flake mixture. Place back into oven and bake another 10 minutes or until top is golden and bubbly. Remove from oven and let stand 5 minutes before serving.