The former Chelsea man notched a goal and an assist as the Premier League side maintained their unbeaten pre-season record, with their lower-league opposition netting a late goal
Sam Allardyce's side had notched up victories against Cork City, Boreham Wood and Bournemouth in their previous outings and goals from Joe Cole and James Collins continued their good form ahead of the new Premier League campaign.
New signing Andy Carroll remained sidelined with a heel injury, while captain Kevin Nolan was not risked after taking a knock in the win over Bournemouth on Saturday. Colchester included former West Ham forward Freddie Sears in their line-up.
The away side did not have to wait long for the breakthrough, as England international Cole scored a highly fortuitous opener. Colchester goalkeeper Mark Cousins' attempted up-field kick rebounded straight off the former Chelsea man and span into the bottom left-hand corner of the net.
Colchester were on the back foot for most of the opening period, but former Sheffield Wednesday striker Clinton Morrison almost levelled the scores. The ball bounced off defender James Collins into the path of Morrison, but his first-time effort was saved by Adrian.
Young striker Elliot Lee then found himself one-on-one with Colchester keeper Mark Cousins in the 39th minute, but his cross-goal effort was saved.
West Ham started the second half as they had the first with an early goal. Cole took a corner from the left, which was met by the head of Collins after the Wales international easily lost his marker.
Modibo Maiga should have put the game beyond doubt with just under 30 minutes remaining, but the Malian somehow sidefooted wide from six yards.
West Ham continued to press with Ricardo Vaz Te looking particularly threatening, but the home side managed to score a consolation with the game heading into injury time.
Tosin Olufemi crossed from the right and Jabo Ibehre raced into the box to thunder his header past Adrian.