Lieutenant Ayers was a Provost (military police whose duties are policing solely within the army).
He was one of three provosts on duty in a small deserted Portuguese village. Their equipment was new, and their faces burned red, indicating that they had newly arrived on the Peninsula.
After some verbal sparring with Captain Sharpe, Lieutenant Ayes and the two other Provosts went to examine Sharpe's men, and he caught Private Batten with a stolen chicken. Ayers determined that Private Batten must hang and only armed intervention by Sharpe and Harper stopped it happening (Sharpe's Gold : Chapter 1).
Subsequently, Sharpe was forced to apologize to an embarrassed Lieutenant Ayers, in the company of the Provost Marshal and Colonel Williams. Sharpe's smart apology caused Ayers to agree to his own regret over the incident, to the confusion of Colonel Williams (Sharpe's Gold : Chapter 3). But the matter was dropped.
In the television movie of the same name, but of a wildly divergent plot, it was a private Skillicorn who had the chicken, and things played out exactly the same - save that Ayers re-arrested the rifleman after the incident was over, and apparently hanged him.
He then accompanied Sharpe on a mission to trade rifles to the partisans for deserters in their camp. He was killed during a raid into the partisan's lair to rescue Ellie and Will Nugent.