Bring a large pot of salted water to boil. Stir in the macaroni. Cook the pasta uncovered, stirring occasionally, until the pasta has cooked through, but is still firm to the bite, about 8 minutes; drain.
Preheat oven to 350 degrees F (175 degrees C).
Spray a 9x13-inch baking dish with cooking spray.
Melt butter in a large skillet over medium-high heat. Cook and stir ham and onion in melted butter until onion is tender, about 5 minutes.
Stir garlic into ham mixture and cook for about 2 minutes more; remove skillet from heat.
Mix cooked pasta, Cheddar cheese, cream of celery soup, peas, milk, sour cream, onion powder, and garlic powder into the ham mixture until well mixed.
Transfer pasta mixture to the prepared baking dish.
Bake in the preheated oven until cheese is melted, about 25 minutes. Sprinkle French-fried onions atop casserole and bake until golden, about 5 minutes more.