Preheat the oven to 350°F (175°C).
Grease a 9x13 inch baking dish.
In a large bowl, combine the diced potatoes, sour cream, shredded cheese, milk, chopped onions, garlic powder, salt, and pepper.
Transfer the mixture into the prepared baking dish and spread it evenly.
If using, sprinkle crushed cornflakes on top of the potato mixture.
Cover the dish with aluminum foil and bake for 30 minutes.
Remove the foil and bake for an additional 15-20 minutes, until the top is golden brown.
Let the casserole cool for 10 minutes before serving.