Two Joe Adams strikes gave the side the win in a match they dominated for large parts.
It was United who started the brighter of the two as they kept possession well and carried a real threat out wide. In fact, it took them just four minutes to go ahead as Ben Worman received the ball on the edge of the box before he turned well and curled a left footed effort into the top left-hand corner leaving Shepperd with little chance of saving.
Much of the opening 15 minutes continued to fall the way of the opponents as Joe Neal saw his low cross turned away before he tried his luck as his shot edged just wide of goal.
On 18 minutes Brentford B got going and created their first attempt when Gustav Mogensen played a lofted ball into the box for one of the Trialists to cushion into the path of Lachlan Brook, but his first time shot sailed over.
The Bees then gained momentum as one of the Trialists shot wide from a tight angle before the lively Ryan Trevitt saw his low effort well blocked after some good build-up play in the midfield. The equaliser continued to look likely when Valgeir Valgeirsson sent a ball into the box, and Mogensen improvised well as he flicked goalwards, but for a clearance off the line.
That goal did come, though, on 35 minutes as Joe Adams, who recently returned from his loan with Grimsby Town, stepped up to curl a fantastic effort with his right foot into the top left corner from just outside the box as the side deservedly levelled.
Just three minutes later the score reversal was complete as some really good incisive play saw Mogensen drift to the left before he crossed perfectly into the path of Adams who finished first time to make it 2-1.
Nathan Shepperd was called into action just seven minutes after the break as United looked for a way back into the game through Nathan Braithwaite, and despite connecting well, the young Welshman dived to his left to push the ball over.
A goal which was ruled out for offside for United was quickly followed up by another Adams attempt as the youngster looked for his hat-trick. Another stunning free-kick arrowed goalwards but for the crossbar which denied the Brentford man his third just after the hour mark.
A Brook shot was followed up by a chance for United as Neal saw his powerful drive stopped by Shepperd, whilst the Cambridge man had a golden chance in the closing moments when United won possession high up field.
Having gained possession, the forward drove at goal and made it into the box, but as he shot one of the Brentford Trialists managed to do enough to put him off as the shot went just wide of goal.
Cambridge United XI: Chadwick, Bennett, Beckett, Jobe, Dickens, Cowling, Tarpey, Warner, Neal, Braithwaite, Sean
Subs: Whitehall, Maragh, Noel, Miller, McConnell, Rider
Brentford B: Shepperd, Valgeirsson (Trialist, 82) Gordon, Trialist (Robb, 45) Trevitt (Carre, 79) Trialist (Trialist, 60) Adams (Hercules, 72) Mogensen, Brook, Trialist (Trialist, 60) Trialist (Trialist, 79)
Subs: Thompson, Trialist