Coulter enrolled in the Westmoreland Guards, a local militia company that was mustered into the United States Army as Company E of the Second Pennsylvania Volunteer Infantry Regiment. It was one of only two regiments sent from Pennsylvania to serve in Mexico. Coulter saw action under General Winfield Scott in the Siege of Vera Cruz and the subsequent battles of Cerro Gordo, Contreras, Churubusco, and Chapultepec, and the capture and occupation of Mexico City in 1847. He served directly under future Civil War general John W. Geary, a man he had little respect for due to his vanity.