“Proving Ground” is episode thirteen of season five of Stargate SG-1.
Colonel O’Neill seems to be leading a squad in pursuit of a Goa’uld that has escaped the SGC, and which has taken control of either Daniel or Major Carter. This is actually a training mission, and O’Neill isn’t too impressed with his trainees.
After the second mission, in which they also perform badly, it turns out that there has been an alien incursion at the SGC – a foothold situation – and O’Neill is left with only the trainees to depend on. One of whom is Hailey, who was last seen in “Prodigy”.
The trainees and O’Neill must infiltrate the SGC and free it.
I’m not sure if I’d seen this one before, or whether I figured out the twist.