Preheat oven to 350F.
Butter a 9x13-inch baking dish and set aside.
To cook the potatoes: either peel and cube them, then boil in salted water until soft; or peel, place in the microwave, and cook on high per your microwave's baked potato instructions.
Once the potatoes are cooked, mash them and transfer to a large bowl.
In a large skillet, warm the oil and toss in the chopped ham, cooking for 4-5 minutes. Add the onion, continuing to cook. Stir often until they turn golden brown, which should take around 10 minutes. Mix in the thyme and marjoram, then take the skillet off the heat.
Add the cooked ham and onion mixture, melted butter, 1 cup of cheese, heavy cream, beaten egg, salt, and pepper to the bowl with the potatoes. Stir all the ingredients together well.
Spoon the mixture into the prepared baking dish.
Bake until heated through, for about 30 minutes. Sprinkle the rest of the cheese and bake until melted, approximately 5 minutes or more.
Serve warm as a side dish.