Derry may have seen performances improve but before kick-off he had seen his side claimed only one point from his first four league games at the helm - but that all changed against Gillingham.
McGregor, on loan from Celtic, scored either side of the break while Jack Grealish also got on the scoresheet as County battled to three points.
The Magpies almost had the lead inside two minutes when Morgan Fox's free-kick was knocked on by Alan Sheehan to Danny Haynes but the striker sliced his shot wide.
Gills' Bradley Dack then came within inches of giving his side the lead in the 15th minute but his finish beat Bartosz Bialkowski and came back off the post.
But just minutes later McGregor gave his side the lead, twisting and turning inside the Gills' defence before seeing his shot deflect off skipper Adam Barrett and beyond the reach of Stuart Nelson.
Within two minutes of the re-start, Gillingham were level - the County defence failed to deal with Charlie Lee's long throw-in and the ball eventually fell to Dack who bundled the ball home.
Gillingham were in control, but completely against the run of play, County re-took the lead. Gary Liddle's low cross found McGregor, who turned before firing in to the roof of the net.
McGregor was proving to be the hero at both ends as he cleared twice off his own goal-line to keep County ahead.
But County sealed their first win in six with four minutes remaining thanks to a wonderful solo goal from Grealish. The Aston Villa loanee beat three Gills defenders and fired into the roof of the net to bag his first goal for the club.