Modibo Maiga scored his first West Ham goal as the Premier League side beat battling visitors Crewe in the League Cup second round.
The Mali striker, a recent signing from Sochaux, pounced from close range when Alex goalkeeper Alan Martin failed to hold Kevin Nolan's shot on 55 minutes.
Former Crewe striker Nicky Maynard refused to celebrate after sweeping home Ricardo Vaz Te's 34th-minute cross for the Hammers' opening goal.
Luke Murphy went closest for Crewe.
Maynard first joined Crewe as a seven-year-old and scored 35 goals in 67 appearances for the Cheshire club before moving to Bristol City in 2008 and then to West Ham in January.
And the 25-year-old, who has been linked with a move away from Upton Park, took his chance to impress against his former club.
Manager Sam Allardyce made 10 changes from Saturday's 3-0 Premier League defeat by Swansea, with captain Kevin Nolan the only survivor as new arrivals Maiga, Alou Diarra and Stephen Henderson made their first starts for the club.
League One Crewe conceded five against Brentford at the weekend but they were resilient at Upton Park until Maynard's opener, a low volley into the bottom corner.
Crewe's Murphy saw a stinging 30-yard shot tipped around the post before the Hammers wrapped up victory when Maiga scored from close range after Nolan's free kick was parried into his path.