In a skillet, saute onions and green pepper in 1 tablespoon butter until tender. Combine onions and pepper with potatoes, ham and mayonnaise; pour into an ungreased 11x7-in. baking dish.
In a saucepan, melt remaining butter. Stir in flour and pepper until smooth. Gradually add milk; bring to a boil. Cook and stir for 1 minute. Stir in cheese just until melted. Pour over potato mixture. Cover and bake at 350° for 30 minutes or until bubbly.