MinErzeuger[p_] := 
      Module[{a = 2}, 
While[
          Not[MultiplicativeOrder[a, p] == p - 1], 
          a = a + 1]; 
a
]

MinErzeuger[p = 10007]

Length[Union[Table[PowerMod[5, n, p], {n, p - 1}]]]