In 1823 he was given command of a unit in the 5th Corps in the Army of the Pyrenees, which took part in the French invasion of Spain.